Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Added internal dstat_aio plugin to see number of asynchronous I/O req…
Browse files Browse the repository at this point in the history
…uests
  • Loading branch information
dagwieers committed Dec 1, 2008
1 parent 37b0dea commit 30a1ec9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added VMware ESX dstat_vmmemctl plugin (Bert de Bruijn)
- Added internal dstat_fs plugin to show number of open files/inodes
- Added internal dstat_socket plugin to show total number of various sockets
- Added internal dstat_aio plugin to see number of asynchronous I/O requests

* 0.6.8 - Buenos Aires - release 12/09/2008
- Added improved tick patch (Kelly Long)
Expand Down
49 changes: 42 additions & 7 deletions dstat
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class Options:
try:
import getopt
opts, args = getopt.getopt (args, 'acdfghilmno:pstTvyC:D:I:M:N:S:V',
['cpu', 'disk', 'epoch', 'fs', 'filesystem', 'int', 'ipc', 'load',
'lock', 'mem', 'net', 'page', 'proc', 'raw', 'socket', 'swap',
'sys', 'tcp', 'time', 'udp', 'unix',
['aio', 'cpu', 'disk', 'epoch', 'fs', 'filesystem', 'int', 'ipc',
'load', 'lock', 'mem', 'net', 'page', 'proc', 'raw', 'socket',
'swap', 'sys', 'tcp', 'time', 'udp', 'unix',
'all', 'debug', 'full', 'help', 'integer', 'mods', 'modules', 'nocolor',
'noheaders', 'noupdate', 'output=', 'pidfile=', 'version', 'vmstat'])
except getopt.error, exc:
Expand All @@ -117,7 +117,9 @@ class Options:
self.modlist = []

for opt, arg in opts:
if opt in ['-c', '--cpu']:
if opt in ['--aio']:
self.modlist.append('cpu')
elif opt in ['-c', '--cpu']:
self.modlist.append('cpu')
elif opt in ['-C']:
self.cpulist = arg.split(',')
Expand Down Expand Up @@ -264,9 +266,13 @@ Dstat options:
-t, --time enable time/date output
-T, --epoch enable time counter (seconds since epoch)
-y, --sys enable system stats
--aio enable aio stats
--fs enable fs stats
--ipc enable ipc stats
--lock enable lock stats
--raw enable raw stats
--socket enable socket stats
--tcp enable tcp stats
--udp enable udp stats
--unix enable unix stats
Expand Down Expand Up @@ -317,7 +323,7 @@ class dstat:
if fd:
self.file.append(filename)
self.fd.append(fd)
if not self.fd:
if not self.fd:
raise Exception, 'Cannot open file %s.' % filename

def readlines(self):
Expand Down Expand Up @@ -470,6 +476,21 @@ class dstat:
return ','
return ''

class dstat_aio(dstat):
def __init__(self):
self.name = 'async'
self.format = ('d', 5, 1000)
self.open('/proc/sys/fs/aio-nr')
self.nick = ('#aio',)
self.vars = ('aio',)
self.init(self.vars, 1)

def extract(self):
for line in self.readlines():
l = line.split()
if len(l) < 1: continue
self.val['aio'] = float(l[0])

class dstat_cpu(dstat):
def __init__(self):
self.format = ('p', 3, 34)
Expand Down Expand Up @@ -827,7 +848,6 @@ class dstat_fs(dstat):
self.vars = ('files', 'inodes')
self.init(self.vars, 1)

### We are now using the starttime instead of the execution time of this plugin
def extract(self):
for line in dopen('/proc/sys/fs/file-nr').readlines():
l = line.split()
Expand Down Expand Up @@ -1198,7 +1218,7 @@ class dstat_raw(dstat):
def extract(self):
lines = -1
for line in self.readlines():
lines = lines + 1
lines = lines + 1
self.val['sockets'] = lines
### Cannot use len() on generator
# self.val['sockets'] = len(self.readlines()) - 1
Expand Down Expand Up @@ -1852,6 +1872,21 @@ def exit(ret):

def listmodules():
rows, cols = gettermsize()
print 'internal:\n\t',
remod = re.compile('dstat_(.+)$')
modlist = []
for filename in globals():
if filename.startswith('dstat_'):
modlist.append(remod.match(filename).groups()[0])
modlist.sort()
cols2 = cols - 8
for mod in modlist:
cols2 = cols2 - len(mod) - 2
if cols2 <= 0:
print '\n\t',
cols2 = cols - len(mod) - 10
print mod + ',',
print
remod = re.compile('.+/dstat_(.+).py$')
for path in sys.path:
modlist = []
Expand Down

0 comments on commit 30a1ec9

Please sign in to comment.