Skip to content
Browse files

Retab

  • Loading branch information...
1 parent c0c7cba commit 57b2b9084f4d25232f923e71a0bf3b1a1e6c9779 @dagwieers committed
View
3,568 dstat
1,784 additions, 1,784 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
3,532 dstat15
1,766 additions, 1,766 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
8 examples/curstest
@@ -6,7 +6,7 @@ import curses, sys
#curses.start_color()
#print "TERM is", curses.termname()
#if curses.has_colors():
-# print "Has colors"#
+# print "Has colors"#
#print curses.color_pair(curses.COLOR_RED), "Red"
#curses.endwin()
@@ -14,10 +14,10 @@ import curses, sys
curses.setupterm()
if sys.stdout.isatty():
- print "Is a TTY"
+ print "Is a TTY"
print "Size is %sx%s" % (curses.tigetnum('lines'), curses.tigetnum('cols'))
if curses.tigetnum('colors') > 0:
- print "Has colors"
- print curses.tigetnum('colors')
+ print "Has colors"
+ print curses.tigetnum('colors')
View
44 examples/devtest.py
@@ -5,28 +5,28 @@
import dstat, time
devices = (
- ( 1, 0, 'ram0'),
- ( 1, 1, 'ram1'),
- ( 3, 1, 'hda1'),
- ( 33, 0, 'hde'),
- ( 7, 0, 'loop0'),
- ( 7, 1, 'loop1'),
- ( 8, 0, '/dev/sda'),
- ( 8, 1, '/dev/sda1'),
- ( 8, 18, '/dev/sdb2'),
- ( 8, 37, '/dev/sdc5'),
- ( 9, 0, 'md0'),
- ( 9, 1, 'md1'),
- ( 9, 2, 'md2'),
- ( 74, 16, '/dev/ida/c2d1'),
- ( 77, 241, '/dev/ida/c5d15p1'),
- ( 98, 0, 'ubd/disc0/disc'),
- ( 98, 16, 'ubd/disc1/disc'),
- (104, 0, 'cciss/c0d0'),
- (104, 2, 'cciss/c0d0p2'),
- (253, 0, 'dm-0'),
- (253, 1, 'dm-1'),
+ ( 1, 0, 'ram0'),
+ ( 1, 1, 'ram1'),
+ ( 3, 1, 'hda1'),
+ ( 33, 0, 'hde'),
+ ( 7, 0, 'loop0'),
+ ( 7, 1, 'loop1'),
+ ( 8, 0, '/dev/sda'),
+ ( 8, 1, '/dev/sda1'),
+ ( 8, 18, '/dev/sdb2'),
+ ( 8, 37, '/dev/sdc5'),
+ ( 9, 0, 'md0'),
+ ( 9, 1, 'md1'),
+ ( 9, 2, 'md2'),
+ ( 74, 16, '/dev/ida/c2d1'),
+ ( 77, 241, '/dev/ida/c5d15p1'),
+ ( 98, 0, 'ubd/disc0/disc'),
+ ( 98, 16, 'ubd/disc1/disc'),
+ (104, 0, 'cciss/c0d0'),
+ (104, 2, 'cciss/c0d0p2'),
+ (253, 0, 'dm-0'),
+ (253, 1, 'dm-1'),
)
for maj, min, device in devices:
- print device, '->', dstat.dev(maj, min)
+ print device, '->', dstat.dev(maj, min)
View
46 examples/mmpipe.py
@@ -2,38 +2,38 @@
import select, sys, os
def readpipe(file, tmout = 0.001):
- "Read available data from pipe"
- ret = ''
- while not select.select([file.fileno()], [], [], tmout)[0]:
- pass
- while select.select([file.fileno()], [], [], tmout)[0]:
- ret = ret + file.read(1)
- return ret.split('\n')
+ "Read available data from pipe"
+ ret = ''
+ while not select.select([file.fileno()], [], [], tmout)[0]:
+ pass
+ while select.select([file.fileno()], [], [], tmout)[0]:
+ ret = ret + file.read(1)
+ return ret.split('\n')
def dpopen(cmd):
- "Open a pipe for reuse, if already opened, return pipes"
- global pipes
- if 'pipes' not in globals().keys(): pipes = {}
- if cmd not in pipes.keys():
- pipes[cmd] = os.popen3(cmd, 't', 0)
- return pipes[cmd]
+ "Open a pipe for reuse, if already opened, return pipes"
+ global pipes
+ if 'pipes' not in globals().keys(): pipes = {}
+ if cmd not in pipes.keys():
+ pipes[cmd] = os.popen3(cmd, 't', 0)
+ return pipes[cmd]
### Unbuffered sys.stdout
sys.stdout = os.fdopen(1, 'w', 0)
### Main entrance
if __name__ == '__main__':
- try:
- stdin, stdout, stderr = dpopen('/usr/lpp/mmfs/bin/mmpmon -p -s')
- stdin.write('reset\n')
- readpipe(stdout)
+ try:
+ stdin, stdout, stderr = dpopen('/usr/lpp/mmfs/bin/mmpmon -p -s')
+ stdin.write('reset\n')
+ readpipe(stdout)
- while True:
- stdin.write('io_s\n')
- for line in readpipe(stdout):
- print line
+ while True:
+ stdin.write('io_s\n')
+ for line in readpipe(stdout):
+ print line
- except KeyboardInterrupt, e:
- print
+ except KeyboardInterrupt, e:
+ print
# vim:ts=4:sw=4
View
24 examples/mstat.py
@@ -17,9 +17,9 @@
### Load stats
stats = []
for o in (dstat.dstat_epoch(), dstat.dstat_cpu(), dstat.dstat_mem(), dstat.dstat_load(), dstat.dstat_disk(), dstat.dstat_sys()):
- try: o.check()
- except Exception, e: print e
- else: stats.append(o)
+ try: o.check()
+ except Exception, e: print e
+ else: stats.append(o)
### Make time stats sub-second
stats[0].format = ('t', 14, 0)
@@ -27,17 +27,17 @@
### Print headers
title1 = title2 = ''
for o in stats:
- title1 = title1 + ' ' + o.title1()
- title2 = title2 + ' ' + o.title2()
+ title1 = title1 + ' ' + o.title1()
+ title2 = title2 + ' ' + o.title2()
print '\n' + title1 + '\n' + title2
### Print stats
for dstat.update in range(count):
- line = ''
- for o in stats:
- o.extract()
- line = line + ' ' + o.show()
- print line + dstat.ansi['reset']
- if dstat.update != count-1: time.sleep(delay)
- dstat.tick = 1
+ line = ''
+ for o in stats:
+ o.extract()
+ line = line + ' ' + o.show()
+ print line + dstat.ansi['reset']
+ if dstat.update != count-1: time.sleep(delay)
+ dstat.tick = 1
print dstat.ansi['reset']
View
4 examples/tdbtest
@@ -6,8 +6,8 @@ print db.keys()
key=db.firstkey()
while key:
- print db.fetch(key)
- key=db.nextkey(key)
+ print db.fetch(key)
+ key=db.nextkey(key)
db = tdb.tdb('/var/cache/samba/locking.tdb')
print db.keys
View
100 plugins/dstat_app.py
@@ -7,62 +7,62 @@
import string
class dstat_app(dstat):
- def __init__(self):
- self.name = 'most expensive'
- self.format = ('s', 18, 0)
- self.nick = ('process',)
- self.vars = self.nick
- self.pid = str(os.getpid())
- self.cn1 = {}; self.cn2 = {}; self.val = {}
+ def __init__(self):
+ self.name = 'most expensive'
+ self.format = ('s', 18, 0)
+ self.nick = ('process',)
+ self.vars = self.nick
+ self.pid = str(os.getpid())
+ self.cn1 = {}; self.cn2 = {}; self.val = {}
- def extract(self):
- max = 0.0
- for pid in os.listdir('/proc/'):
- try: int(pid)
- except: continue
- if os.path.exists('/proc/%s/stat' % pid):
- if pid == self.pid: continue
- if not self.cn1.has_key(pid):
- self.cn1[pid] = 0
+ def extract(self):
+ max = 0.0
+ for pid in os.listdir('/proc/'):
+ try: int(pid)
+ except: continue
+ if os.path.exists('/proc/%s/stat' % pid):
+ if pid == self.pid: continue
+ if not self.cn1.has_key(pid):
+ self.cn1[pid] = 0
- ### Using dopen() will cause too many open files
-# l = string.split(dopen('/proc/%s/stat' % pid).read())
- l = string.split(open('/proc/%s/stat' % pid).read())
- if len(l) < 15: continue
- self.cn2[pid] = int(l[13]) + int(l[14])
- usage = (self.cn2[pid] - self.cn1[pid]) * 1.0 / tick
+ ### Using dopen() will cause too many open files
+# l = string.split(dopen('/proc/%s/stat' % pid).read())
+ l = string.split(open('/proc/%s/stat' % pid).read())
+ if len(l) < 15: continue
+ self.cn2[pid] = int(l[13]) + int(l[14])
+ usage = (self.cn2[pid] - self.cn1[pid]) * 1.0 / tick
- ### Get the process that spends the most jiffies
- if usage > max:
- max = usage
- self.val['name'] = l[1][1:-1]
- self.val['pid'] = pid
+ ### Get the process that spends the most jiffies
+ if usage > max:
+ max = usage
+ self.val['name'] = l[1][1:-1]
+ self.val['pid'] = pid
- if max == 0.0:
- self.val['process'] = ''
- else:
- ### If the name is a known interpreter, take the second argument from the cmdline
- if self.val['name'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
- ### Using dopen() will cause too many open files
-# l = string.split(dopen('/proc/%s/cmdline' % self.val['pid']).read(), '\0')
- l = string.split(open('/proc/%s/cmdline' % self.val['pid']).read(), '\0')
- if len(l) > 2:
- self.val['name'] = os.path.basename(l[1])
+ if max == 0.0:
+ self.val['process'] = ''
+ else:
+ ### If the name is a known interpreter, take the second argument from the cmdline
+ if self.val['name'] in ('bash', 'csh', 'ksh', 'perl', 'python', 'sh'):
+ ### Using dopen() will cause too many open files
+# l = string.split(dopen('/proc/%s/cmdline' % self.val['pid']).read(), '\0')
+ l = string.split(open('/proc/%s/cmdline' % self.val['pid']).read(), '\0')
+ if len(l) > 2:
+ self.val['name'] = os.path.basename(l[1])
-# l = l.reverse()
-# for x in l:
-# print x
-# if x[0] != '-':
-# self.val['name'] = os.path.basename(x)
-# break
+# l = l.reverse()
+# for x in l:
+# print x
+# if x[0] != '-':
+# self.val['name'] = os.path.basename(x)
+# break
- ### Show yellow usage
- self.val['process'] = '%-*s%s%3d' % (self.format[1]-3, self.val['name'], ansi['yellow'], round(max))
+ ### Show yellow usage
+ self.val['process'] = '%-*s%s%3d' % (self.format[1]-3, self.val['name'], ansi['yellow'], round(max))
- ### Debug (show PID)
-# self.val['process'] = '%*s %-*s' % (5, self.val['pid'], self.format[1]-6, self.val['name'])
+ ### Debug (show PID)
+# self.val['process'] = '%*s %-*s' % (5, self.val['pid'], self.format[1]-6, self.val['name'])
- if step == op.delay:
- self.cn1.update(self.cn2)
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
68 plugins/dstat_battery.py
@@ -7,39 +7,39 @@
import string
class dstat_battery(dstat):
- def __init__(self):
- self.name = 'battery'
- self.format = ('f', 4, 34)
- self.vars = []
- for battery in os.listdir('/proc/acpi/battery/'):
- for line in dopen('/proc/acpi/battery/'+battery+'/state').readlines():
- l = string.split(line)
- if len(l) < 2: continue
- if l[0] == 'present:' and l[1] == 'yes':
- self.vars.append(battery)
-# self.nick = [string.lower(name) for name in self.vars]
- self.nick = []
- for name in self.vars:
- self.nick.append(string.lower(name))
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'battery'
+ self.format = ('f', 4, 34)
+ self.vars = []
+ for battery in os.listdir('/proc/acpi/battery/'):
+ for line in dopen('/proc/acpi/battery/'+battery+'/state').readlines():
+ l = string.split(line)
+ if len(l) < 2: continue
+ if l[0] == 'present:' and l[1] == 'yes':
+ self.vars.append(battery)
+# self.nick = [string.lower(name) for name in self.vars]
+ self.nick = []
+ for name in self.vars:
+ self.nick.append(string.lower(name))
+ self.init(self.vars, 1)
- def extract(self):
- for battery in self.vars:
- for line in dopen('/proc/acpi/battery/'+battery+'/info').readlines():
- l = string.split(line)
- if len(l) < 4: continue
- if l[0] == 'last':
- full = int(l[3])
- break
- for line in dopen('/proc/acpi/battery/'+battery+'/state').readlines():
- l = string.split(line)
- if len(l) < 3: continue
- if l[0] == 'remaining':
- current = int(l[2])
- break
- if current:
- self.val[battery] = current * 100.0 / full
- else:
- self.val[battery] = -1
+ def extract(self):
+ for battery in self.vars:
+ for line in dopen('/proc/acpi/battery/'+battery+'/info').readlines():
+ l = string.split(line)
+ if len(l) < 4: continue
+ if l[0] == 'last':
+ full = int(l[3])
+ break
+ for line in dopen('/proc/acpi/battery/'+battery+'/state').readlines():
+ l = string.split(line)
+ if len(l) < 3: continue
+ if l[0] == 'remaining':
+ current = int(l[2])
+ break
+ if current:
+ self.val[battery] = current * 100.0 / full
+ else:
+ self.val[battery] = -1
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
56 plugins/dstat_cpufreq.py
@@ -7,34 +7,34 @@
import string
class dstat_cpufreq(dstat):
- def __init__(self):
- self.name = 'frequency'
- self.format = ('p', 4, 34)
- self.vars = os.listdir('/sys/devices/system/cpu/')
-# self.nick = [string.lower(name) for name in self.vars]
- self.nick = []
- for name in self.vars:
- self.nick.append(string.lower(name))
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'frequency'
+ self.format = ('p', 4, 34)
+ self.vars = os.listdir('/sys/devices/system/cpu/')
+# self.nick = [string.lower(name) for name in self.vars]
+ self.nick = []
+ for name in self.vars:
+ self.nick.append(string.lower(name))
+ self.init(self.vars, 1)
- def check(self):
- if self.vars:
- for cpu in self.vars:
- if not os.access('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_cur_freq', os.R_OK):
- raise Exception, 'Cannot access acpi cpu frequency information'
- return True
- raise Exception, 'No statistics found'
+ def check(self):
+ if self.vars:
+ for cpu in self.vars:
+ if not os.access('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_cur_freq', os.R_OK):
+ raise Exception, 'Cannot access acpi cpu frequency information'
+ return True
+ raise Exception, 'No statistics found'
- def extract(self):
- for cpu in self.vars:
- for line in dopen('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_max_freq').readlines():
- l = string.split(line)
- max = int(l[0])
- for line in dopen('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_cur_freq').readlines():
- l = string.split(line)
- cur = int(l[0])
- ### Need to close because of bug in sysfs (?)
- dclose('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_cur_freq')
- self.val[cpu] = cur * 100.0 / max
+ def extract(self):
+ for cpu in self.vars:
+ for line in dopen('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_max_freq').readlines():
+ l = string.split(line)
+ max = int(l[0])
+ for line in dopen('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_cur_freq').readlines():
+ l = string.split(line)
+ cur = int(l[0])
+ ### Need to close because of bug in sysfs (?)
+ dclose('/sys/devices/system/cpu/'+cpu+'/cpufreq/cpuinfo_cur_freq')
+ self.val[cpu] = cur * 100.0 / max
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
64 plugins/dstat_dbus.py
@@ -4,38 +4,38 @@
### Authority: dag@wieers.com
class dstat_dbus(dstat):
- def __init__(self):
- self.name = 'dbus'
- self.format = ('d', 3, 100)
- self.nick = ('sys', 'ses')
- self.vars = ('system', 'session')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'dbus'
+ self.format = ('d', 3, 100)
+ self.nick = ('sys', 'ses')
+ self.vars = ('system', 'session')
+ self.init(self.vars, 1)
- def check(self):
-# dstat.info(1, 'The dbus module is an EXPERIMENTAL module.')
- try:
- global dbus
- import dbus
- try:
- self.sysbus = dbus.Bus(dbus.Bus.TYPE_SYSTEM).get_service('org.freedesktop.DBus').get_object('/org/freedesktop/DBus', 'org.freedesktop.DBus')
- try:
- self.sesbus = dbus.Bus(dbus.Bus.TYPE_SESSION).get_service('org.freedesktop.DBus').get_object('/org/freedesktop/DBus', 'org.freedesktop.DBus')
- except:
- self.sesbus = None
- except:
- raise Exception, 'Unable to connect to dbus message bus'
- return True
- except:
- raise Exception, 'Needs python-dbus module'
+ def check(self):
+# dstat.info(1, 'The dbus module is an EXPERIMENTAL module.')
+ try:
+ global dbus
+ import dbus
+ try:
+ self.sysbus = dbus.Bus(dbus.Bus.TYPE_SYSTEM).get_service('org.freedesktop.DBus').get_object('/org/freedesktop/DBus', 'org.freedesktop.DBus')
+ try:
+ self.sesbus = dbus.Bus(dbus.Bus.TYPE_SESSION).get_service('org.freedesktop.DBus').get_object('/org/freedesktop/DBus', 'org.freedesktop.DBus')
+ except:
+ self.sesbus = None
+ except:
+ raise Exception, 'Unable to connect to dbus message bus'
+ return True
+ except:
+ raise Exception, 'Needs python-dbus module'
- def extract(self):
- self.val['system'] = len(self.sysbus.ListServices()) - 1
- try:
- self.val['session'] = len(self.sesbus.ListServices()) - 1
- except:
- self.val['session'] = -1
-# print dir(b); print dir(s); print dir(d); print d.ListServices()
-# print dir(d)
-# print d.ListServices()
+ def extract(self):
+ self.val['system'] = len(self.sysbus.ListServices()) - 1
+ try:
+ self.val['session'] = len(self.sesbus.ListServices()) - 1
+ except:
+ self.val['session'] = -1
+# print dir(b); print dir(s); print dir(d); print d.ListServices()
+# print dir(d)
+# print d.ListServices()
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
60 plugins/dstat_freespace.py
@@ -6,36 +6,36 @@
import string
class dstat_freespace(dstat):
- def __init__(self):
- self.format = ('f', 5, 1024)
- self.open('/etc/mtab')
- self.vars = self.vars()
-# self.name = ['/' + os.path.basename(name) for name in self.vars]
- self.name = []
- for name in self.vars:
- self.name.append('/' + os.path.basename(name))
- self.nick = ('used', 'free')
- self.init(self.vars + ['total',], 2)
+ def __init__(self):
+ self.format = ('f', 5, 1024)
+ self.open('/etc/mtab')
+ self.vars = self.vars()
+# self.name = ['/' + os.path.basename(name) for name in self.vars]
+ self.name = []
+ for name in self.vars:
+ self.name.append('/' + os.path.basename(name))
+ self.nick = ('used', 'free')
+ self.init(self.vars + ['total',], 2)
- def vars(self):
- ret = []
- for line in self.readlines():
- l = string.split(line)
- if len(l) < 6: continue
- if l[2] in ('binfmt_misc', 'devpts', 'iso9660', 'none', 'proc', 'sysfs', 'usbfs'): continue
- ### FIXME: Excluding 'none' here may not be what people want (/dev/shm)
- if l[0] in ('devpts', 'none', 'proc', 'sunrpc', 'usbfs'): continue
- name = l[1]
- res = os.statvfs(name)
- if res[0] == 0: continue ### Skip zero block filesystems
- ret.append(name)
- return ret
+ def vars(self):
+ ret = []
+ for line in self.readlines():
+ l = string.split(line)
+ if len(l) < 6: continue
+ if l[2] in ('binfmt_misc', 'devpts', 'iso9660', 'none', 'proc', 'sysfs', 'usbfs'): continue
+ ### FIXME: Excluding 'none' here may not be what people want (/dev/shm)
+ if l[0] in ('devpts', 'none', 'proc', 'sunrpc', 'usbfs'): continue
+ name = l[1]
+ res = os.statvfs(name)
+ if res[0] == 0: continue ### Skip zero block filesystems
+ ret.append(name)
+ return ret
- def extract(self):
- self.val['total'] = (0, 0)
- for name in self.vars:
- res = os.statvfs(name)
- self.val[name] = ( (float(res.f_blocks) - float(res.f_bavail)) * long(res.f_frsize), float(res.f_bavail) * float(res.f_frsize) )
- self.val['total'] = (self.val['total'][0] + self.val[name][0], self.val['total'][1] + self.val[name][1])
+ def extract(self):
+ self.val['total'] = (0, 0)
+ for name in self.vars:
+ res = os.statvfs(name)
+ self.val[name] = ( (float(res.f_blocks) - float(res.f_bavail)) * long(res.f_frsize), float(res.f_bavail) * float(res.f_frsize) )
+ self.val['total'] = (self.val['total'][0] + self.val[name][0], self.val['total'][1] + self.val[name][1])
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
72 plugins/dstat_gpfs.py
@@ -2,43 +2,43 @@
import string, select
class dstat_gpfs(dstat):
- def __init__(self):
- self.name = 'gpfs i/o'
- self.format = ('f', 5, 1024)
- self.vars = ('_br_', '_bw_')
- self.nick = ('read', 'write')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'gpfs i/o'
+ self.format = ('f', 5, 1024)
+ self.vars = ('_br_', '_bw_')
+ self.nick = ('read', 'write')
+ self.init(self.vars, 1)
- def check(self):
- if os.access('/usr/lpp/mmfs/bin/mmpmon', os.X_OK):
- try:
- self.stdin, self.stdout, self.stderr = dpopen('/usr/lpp/mmfs/bin/mmpmon -p -s')
- self.stdin.write('reset\n')
- readpipe(self.stdout)
- except IOError:
- raise Exception, 'Cannot interface with gpfs mmpmon binary'
- return True
- raise Exception, 'Needs GPFS mmpmon binary'
+ def check(self):
+ if os.access('/usr/lpp/mmfs/bin/mmpmon', os.X_OK):
+ try:
+ self.stdin, self.stdout, self.stderr = dpopen('/usr/lpp/mmfs/bin/mmpmon -p -s')
+ self.stdin.write('reset\n')
+ readpipe(self.stdout)
+ except IOError:
+ raise Exception, 'Cannot interface with gpfs mmpmon binary'
+ return True
+ raise Exception, 'Needs GPFS mmpmon binary'
- def extract(self):
- try:
- self.stdin.write('io_s\n')
-# readpipe(self.stderr)
- for line in readpipe(self.stdout):
- if not line: continue
- l = line.split()
- for name in self.vars:
- self.cn2[name] = long(l[l.index(name)+1])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- except IOError, e:
- for name in self.vars: self.val[name] = -1
-# print 'dstat_gpfs: lost pipe to mmpmon,', e
- except Exception, e:
- for name in self.vars: self.val[name] = -1
-# print 'dstat_gpfs: exception', e
+ def extract(self):
+ try:
+ self.stdin.write('io_s\n')
+# readpipe(self.stderr)
+ for line in readpipe(self.stdout):
+ if not line: continue
+ l = line.split()
+ for name in self.vars:
+ self.cn2[name] = long(l[l.index(name)+1])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ except IOError, e:
+ for name in self.vars: self.val[name] = -1
+# print 'dstat_gpfs: lost pipe to mmpmon,', e
+ except Exception, e:
+ for name in self.vars: self.val[name] = -1
+# print 'dstat_gpfs: exception', e
- if step == op.delay:
- self.cn1.update(self.cn2)
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
72 plugins/dstat_gpfsop.py
@@ -2,43 +2,43 @@
import string, select
class dstat_gpfsop(dstat):
- def __init__(self):
- self.name = 'gpfs file operations'
- self.format = ('d', 5, 1000)
- self.vars = ('_oc_', '_cc_', '_rdc_', '_wc_', '_dir_', '_iu_')
- self.nick = ('open', 'clos', 'read', 'writ', 'rdir', 'inod')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'gpfs file operations'
+ self.format = ('d', 5, 1000)
+ self.vars = ('_oc_', '_cc_', '_rdc_', '_wc_', '_dir_', '_iu_')
+ self.nick = ('open', 'clos', 'read', 'writ', 'rdir', 'inod')
+ self.init(self.vars, 1)
- def check(self):
- if os.access('/usr/lpp/mmfs/bin/mmpmon', os.X_OK):
- try:
- self.stdin, self.stdout, self.stderr = dpopen('/usr/lpp/mmfs/bin/mmpmon -p -s')
- self.stdin.write('reset\n')
- readpipe(self.stdout)
- except IOError:
- raise Exception, 'Cannot interface with gpfs mmpmon binary'
- return True
- raise Exception, 'Needs GPFS mmpmon binary'
+ def check(self):
+ if os.access('/usr/lpp/mmfs/bin/mmpmon', os.X_OK):
+ try:
+ self.stdin, self.stdout, self.stderr = dpopen('/usr/lpp/mmfs/bin/mmpmon -p -s')
+ self.stdin.write('reset\n')
+ readpipe(self.stdout)
+ except IOError:
+ raise Exception, 'Cannot interface with gpfs mmpmon binary'
+ return True
+ raise Exception, 'Needs GPFS mmpmon binary'
- def extract(self):
- try:
- self.stdin.write('io_s\n')
-# readpipe(self.stderr)
- for line in readpipe(self.stdout):
- if not line: continue
- l = line.split()
- for name in self.vars:
- self.cn2[name] = long(l[l.index(name)+1])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- except IOError, e:
- for name in self.vars: self.val[name] = -1
-# print 'dstat_gpfs: lost pipe to mmpmon,', e
- except Exception, e:
- for name in self.vars: self.val[name] = -1
-# print 'dstat_gpfs: exception', e
+ def extract(self):
+ try:
+ self.stdin.write('io_s\n')
+# readpipe(self.stderr)
+ for line in readpipe(self.stdout):
+ if not line: continue
+ l = line.split()
+ for name in self.vars:
+ self.cn2[name] = long(l[l.index(name)+1])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ except IOError, e:
+ for name in self.vars: self.val[name] = -1
+# print 'dstat_gpfs: lost pipe to mmpmon,', e
+ except Exception, e:
+ for name in self.vars: self.val[name] = -1
+# print 'dstat_gpfs: exception', e
- if step == op.delay:
- self.cn1.update(self.cn2)
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
46 plugins/dstat_nfs3.py
@@ -2,28 +2,28 @@
import string
class dstat_nfs3(dstat):
- def __init__(self):
- self.name = 'nfs3 client'
- self.format = ('d', 5, 1000)
- self.open('/proc/net/rpc/nfs')
- self.vars = ('read', 'write', 'readdir', 'inode', 'filesystem', 'commit')
- self.nick = ('read', 'writ', 'rdir', 'inod', 'fs', 'cmmt')
- self.init(self.vars, 1)
- info(1, 'Module dstat_nfs3 is still experimental.')
+ def __init__(self):
+ self.name = 'nfs3 client'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/net/rpc/nfs')
+ self.vars = ('read', 'write', 'readdir', 'inode', 'filesystem', 'commit')
+ self.nick = ('read', 'writ', 'rdir', 'inod', 'fs', 'cmmt')
+ self.init(self.vars, 1)
+ info(1, 'Module dstat_nfs3 is still experimental.')
- def extract(self):
- for line in self.readlines():
- l = line.split()
- if not l or l[0] != 'proc3': continue
- self.cn2['read'] = long(l[8])
- self.cn2['write'] = long(l[9])
- self.cn2['readdir'] = long(l[17]) + long(l[18])
- self.cn2['inode'] = long(l[3]) + long(l[4]) + long(l[5]) + long(l[6]) + long(l[7]) + long(l[10]) + long(l[11]) + long(l[12]) + long(l[13]) + long(l[14]) + long(l[15]) + long(l[16])
- self.cn2['filesystem'] = long(l[19]) + long(l[20]) + long(l[21])
- self.cn2['commit'] = long(l[22])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if not l or l[0] != 'proc3': continue
+ self.cn2['read'] = long(l[8])
+ self.cn2['write'] = long(l[9])
+ self.cn2['readdir'] = long(l[17]) + long(l[18])
+ self.cn2['inode'] = long(l[3]) + long(l[4]) + long(l[5]) + long(l[6]) + long(l[7]) + long(l[10]) + long(l[11]) + long(l[12]) + long(l[13]) + long(l[14]) + long(l[15]) + long(l[16])
+ self.cn2['filesystem'] = long(l[19]) + long(l[20]) + long(l[21])
+ self.cn2['commit'] = long(l[22])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
38 plugins/dstat_nfs3op.py
@@ -2,24 +2,24 @@
import string
class dstat_nfs3op(dstat):
- def __init__(self):
- self.name = 'extended nfs3 client operations'
- self.format = ('d', 5, 1000)
- self.open('/proc/net/rpc/nfs')
- self.vars = ('null', 'getattr', 'setattr', 'lookup', 'access', 'readlink', 'read', 'write', 'create', 'mkdir', 'symlink', 'mknod', 'remove', 'rmdir', 'rename', 'link', 'readdir', 'readdirplus', 'fsstat', 'fsinfo', 'pathconf', 'commit')
- self.nick = ('null', 'gatr', 'satr', 'look', 'aces', 'rdln', 'read', 'writ', 'crea', 'mkdr', 'syml', 'mknd', 'rm', 'rmdr', 'ren', 'link', 'rdir', 'rdr+', 'fstt', 'fsnf', 'path', 'cmmt')
- self.init(self.vars, 1)
- info(1, 'Module dstat_nfs3op is still experimental.')
+ def __init__(self):
+ self.name = 'extended nfs3 client operations'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/net/rpc/nfs')
+ self.vars = ('null', 'getattr', 'setattr', 'lookup', 'access', 'readlink', 'read', 'write', 'create', 'mkdir', 'symlink', 'mknod', 'remove', 'rmdir', 'rename', 'link', 'readdir', 'readdirplus', 'fsstat', 'fsinfo', 'pathconf', 'commit')
+ self.nick = ('null', 'gatr', 'satr', 'look', 'aces', 'rdln', 'read', 'writ', 'crea', 'mkdr', 'syml', 'mknd', 'rm', 'rmdr', 'ren', 'link', 'rdir', 'rdr+', 'fstt', 'fsnf', 'path', 'cmmt')
+ self.init(self.vars, 1)
+ info(1, 'Module dstat_nfs3op is still experimental.')
- def extract(self):
- for line in self.readlines():
- l = line.split()
- if not l or l[0] != 'proc3': continue
- for i, name in enumerate(self.vars):
- self.cn2[name] = long(l[i+2])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if not l or l[0] != 'proc3': continue
+ for i, name in enumerate(self.vars):
+ self.cn2[name] = long(l[i+2])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
46 plugins/dstat_nfsd3.py
@@ -2,28 +2,28 @@
import string
class dstat_nfsd3(dstat):
- def __init__(self):
- self.name = 'nfs3 server'
- self.format = ('d', 5, 1000)
- self.open('/proc/net/rpc/nfsd')
- self.vars = ('read', 'write', 'readdir', 'inode', 'filesystem', 'commit')
- self.nick = ('read', 'writ', 'rdir', 'inod', 'fs', 'cmmt')
- self.init(self.vars, 1)
- info(1, 'Module dstat_nfsd3 is still experimental.')
+ def __init__(self):
+ self.name = 'nfs3 server'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/net/rpc/nfsd')
+ self.vars = ('read', 'write', 'readdir', 'inode', 'filesystem', 'commit')
+ self.nick = ('read', 'writ', 'rdir', 'inod', 'fs', 'cmmt')
+ self.init(self.vars, 1)
+ info(1, 'Module dstat_nfsd3 is still experimental.')
- def extract(self):
- for line in self.readlines():
- l = line.split()
- if not l or l[0] != 'proc3': continue
- self.cn2['read'] = long(l[8])
- self.cn2['write'] = long(l[9])
- self.cn2['readdir'] = long(l[18]) + long(l[19])
- self.cn2['inode'] = long(l[3]) + long(l[4]) + long(l[5]) + long(l[6]) + long(l[7]) + long(l[10]) + long(l[11]) + long(l[12]) + long(l[13]) + long(l[14]) + long(l[15]) + long(l[16]) + long(l[17])
- self.cn2['filesystem'] = long(l[20]) + long(l[21]) + long(l[22])
- self.cn2['commit'] = long(l[23])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if not l or l[0] != 'proc3': continue
+ self.cn2['read'] = long(l[8])
+ self.cn2['write'] = long(l[9])
+ self.cn2['readdir'] = long(l[18]) + long(l[19])
+ self.cn2['inode'] = long(l[3]) + long(l[4]) + long(l[5]) + long(l[6]) + long(l[7]) + long(l[10]) + long(l[11]) + long(l[12]) + long(l[13]) + long(l[14]) + long(l[15]) + long(l[16]) + long(l[17])
+ self.cn2['filesystem'] = long(l[20]) + long(l[21]) + long(l[22])
+ self.cn2['commit'] = long(l[23])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
38 plugins/dstat_nfsd3op.py
@@ -2,24 +2,24 @@
import string
class dstat_nfsd3op(dstat):
- def __init__(self):
- self.name = 'extended nfs3 server operations'
- self.format = ('d', 5, 1000)
- self.open('/proc/net/rpc/nfsd')
- self.vars = ('null', 'getattr', 'setattr', 'lookup', 'access', 'readlink', 'read', 'write', 'create', 'mkdir', 'symlink', 'mknod', 'remove', 'rmdir', 'rename', 'link', 'readdir', 'readdirplus', 'fsstat', 'fsinfo', 'pathconf', 'commit')
- self.nick = ('null', 'gatr', 'satr', 'look', 'aces', 'rdln', 'read', 'writ', 'crea', 'mkdr', 'syml', 'mknd', 'rm', 'rmdr', 'ren', 'link', 'rdir', 'rdr+', 'fstt', 'fsnf', 'path', 'cmmt')
- self.init(self.vars, 1)
- info(1, 'Module dstat_nfsd3op is still experimental.')
+ def __init__(self):
+ self.name = 'extended nfs3 server operations'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/net/rpc/nfsd')
+ self.vars = ('null', 'getattr', 'setattr', 'lookup', 'access', 'readlink', 'read', 'write', 'create', 'mkdir', 'symlink', 'mknod', 'remove', 'rmdir', 'rename', 'link', 'readdir', 'readdirplus', 'fsstat', 'fsinfo', 'pathconf', 'commit')
+ self.nick = ('null', 'gatr', 'satr', 'look', 'aces', 'rdln', 'read', 'writ', 'crea', 'mkdr', 'syml', 'mknd', 'rm', 'rmdr', 'ren', 'link', 'rdir', 'rdr+', 'fstt', 'fsnf', 'path', 'cmmt')
+ self.init(self.vars, 1)
+ info(1, 'Module dstat_nfsd3op is still experimental.')
- def extract(self):
- for line in self.readlines():
- l = line.split()
- if not l or l[0] != 'proc3': continue
- for i, name in enumerate(self.vars):
- self.cn2[name] = long(l[i+2])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if not l or l[0] != 'proc3': continue
+ for i, name in enumerate(self.vars):
+ self.cn2[name] = long(l[i+2])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
28 plugins/dstat_postfix.py
@@ -2,20 +2,20 @@
import glob
class dstat_postfix(dstat):
- def __init__(self):
- self.name = 'postfix'
- self.format = ('d', 4, 100)
- self.vars = ('incoming', 'active', 'deferred', 'bounce', 'defer')
- self.nick = ('inco', 'actv', 'dfrd', 'bnce', 'defr')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'postfix'
+ self.format = ('d', 4, 100)
+ self.vars = ('incoming', 'active', 'deferred', 'bounce', 'defer')
+ self.nick = ('inco', 'actv', 'dfrd', 'bnce', 'defr')
+ self.init(self.vars, 1)
- def check(self):
- if not os.access('/var/spool/postfix/active', os.R_OK):
- raise Exception, 'Cannot access postfix queues'
- return True
+ def check(self):
+ if not os.access('/var/spool/postfix/active', os.R_OK):
+ raise Exception, 'Cannot access postfix queues'
+ return True
- def extract(self):
- for item in self.vars:
- self.val[item] = len(glob.glob('/var/spool/postfix/'+item+'/*/*'))
+ def extract(self):
+ for item in self.vars:
+ self.val[item] = len(glob.glob('/var/spool/postfix/'+item+'/*/*'))
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
36 plugins/dstat_rpc.py
@@ -2,23 +2,23 @@
import string
class dstat_rpc(dstat):
- def __init__(self):
- self.name = 'rpc client'
- self.format = ('d', 5, 1000)
- self.open('/proc/net/rpc/nfs')
- self.vars = ('calls', 'retransmits', 'autorefreshes')
- self.nick = ('call', 'retr', 'refr')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'rpc client'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/net/rpc/nfs')
+ self.vars = ('calls', 'retransmits', 'autorefreshes')
+ self.nick = ('call', 'retr', 'refr')
+ self.init(self.vars, 1)
- def extract(self):
- for line in self.readlines():
- l = line.split()
- if not l or l[0] != 'rpc': continue
- for i, name in enumerate(self.vars):
- self.cn2[name] = long(l[i+1])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if not l or l[0] != 'rpc': continue
+ for i, name in enumerate(self.vars):
+ self.cn2[name] = long(l[i+1])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
36 plugins/dstat_rpcd.py
@@ -2,23 +2,23 @@
import string
class dstat_rpcd(dstat):
- def __init__(self):
- self.name = 'rpc server'
- self.format = ('d', 5, 1000)
- self.open('/proc/net/rpc/nfsd')
- self.vars = ('calls', 'badcalls', 'badauth', 'badclnt', 'xdrcall')
- self.nick = ('call', 'erca', 'erau', 'ercl', 'xdrc')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'rpc server'
+ self.format = ('d', 5, 1000)
+ self.open('/proc/net/rpc/nfsd')
+ self.vars = ('calls', 'badcalls', 'badauth', 'badclnt', 'xdrcall')
+ self.nick = ('call', 'erca', 'erau', 'ercl', 'xdrc')
+ self.init(self.vars, 1)
- def extract(self):
- for line in self.readlines():
- l = line.split()
- if not l or l[0] != 'rpc': continue
- for i, name in enumerate(self.vars):
- self.cn2[name] = long(l[i+1])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for line in self.readlines():
+ l = line.split()
+ if not l or l[0] != 'rpc': continue
+ for i, name in enumerate(self.vars):
+ self.cn2[name] = long(l[i+1])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
26 plugins/dstat_sendmail.py
@@ -3,19 +3,19 @@
import glob
class dstat_sendmail(dstat):
- def __init__(self):
- self.name = 'sendmail'
- self.format = ('d', 4, 100)
- self.vars = ('queue',)
- self.nick = ('queu',)
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'sendmail'
+ self.format = ('d', 4, 100)
+ self.vars = ('queue',)
+ self.nick = ('queu',)
+ self.init(self.vars, 1)
- def check(self):
- if not os.access('/var/spool/mqueue', os.R_OK):
- raise Exception, 'Cannot access sendmail queue'
- return True
+ def check(self):
+ if not os.access('/var/spool/mqueue', os.R_OK):
+ raise Exception, 'Cannot access sendmail queue'
+ return True
- def extract(self):
- self.val['queue'] = len(glob.glob('/var/spool/mqueue/qf*'))
+ def extract(self):
+ self.val['queue'] = len(glob.glob('/var/spool/mqueue/qf*'))
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
68 plugins/dstat_thermal.py
@@ -2,39 +2,39 @@
import string
class dstat_thermal(dstat):
- def __init__(self):
- self.name = 'thermal'
- self.format = ('d', 4, 20)
- if os.path.exists('/proc/acpi/ibm/thermal'):
- self.namelist = ['cpu', 'pci', 'hdd', 'cpu', 'bat0', 'unk', 'bat1', 'unk']
- self.nick = []
- for line in dopen('/proc/acpi/ibm/thermal'):
- l = string.split(line)
- for i, name in enumerate(self.namelist):
- if int(l[i+1]) > 0:
- self.nick.append(name)
- self.vars = self.nick
- elif os.path.exists('/proc/acpi/thermal_zone/'):
- self.vars = os.listdir('/proc/acpi/thermal_zone/')
-# self.nick = [string.lower(name) for name in self.vars]
- self.nick = []
- for name in self.vars:
- self.nick.append(string.lower(name))
- else:
- raise Exception, 'Needs kernel ACPI or IBM-ACPI support'
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'thermal'
+ self.format = ('d', 4, 20)
+ if os.path.exists('/proc/acpi/ibm/thermal'):
+ self.namelist = ['cpu', 'pci', 'hdd', 'cpu', 'bat0', 'unk', 'bat1', 'unk']
+ self.nick = []
+ for line in dopen('/proc/acpi/ibm/thermal'):
+ l = string.split(line)
+ for i, name in enumerate(self.namelist):
+ if int(l[i+1]) > 0:
+ self.nick.append(name)
+ self.vars = self.nick
+ elif os.path.exists('/proc/acpi/thermal_zone/'):
+ self.vars = os.listdir('/proc/acpi/thermal_zone/')
+# self.nick = [string.lower(name) for name in self.vars]
+ self.nick = []
+ for name in self.vars:
+ self.nick.append(string.lower(name))
+ else:
+ raise Exception, 'Needs kernel ACPI or IBM-ACPI support'
+ self.init(self.vars, 1)
- def extract(self):
- if os.path.exists('/proc/acpi/ibm/thermal'):
- for line in dopen('/proc/acpi/ibm/thermal'):
- l = string.split(line)
- for i, name in enumerate(self.namelist):
- if int(l[i+1]) > 0:
- self.val[name] = int(l[i+1])
- elif os.path.exists('/proc/acpi/thermal_zone/'):
- for zone in self.vars:
- for line in dopen('/proc/acpi/thermal_zone/'+zone+'/temperature').readlines():
- l = string.split(line)
- self.val[zone] = int(l[1])
+ def extract(self):
+ if os.path.exists('/proc/acpi/ibm/thermal'):
+ for line in dopen('/proc/acpi/ibm/thermal'):
+ l = string.split(line)
+ for i, name in enumerate(self.namelist):
+ if int(l[i+1]) > 0:
+ self.val[name] = int(l[i+1])
+ elif os.path.exists('/proc/acpi/thermal_zone/'):
+ for zone in self.vars:
+ for line in dopen('/proc/acpi/thermal_zone/'+zone+'/temperature').readlines():
+ l = string.split(line)
+ self.val[zone] = int(l[1])
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
46 plugins/dstat_utmp.py
@@ -1,27 +1,27 @@
class dstat_utmp(dstat):
- def __init__(self):
- self.name = 'utmp'
- self.format = ('d', 3, 10)
- self.nick = ('ses', 'usr', 'adm' )
- self.vars = ('sessions', 'users', 'root')
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'utmp'
+ self.format = ('d', 3, 10)
+ self.nick = ('ses', 'usr', 'adm' )
+ self.vars = ('sessions', 'users', 'root')
+ self.init(self.vars, 1)
- def check(self):
- try:
- global utmp
- import utmp
- return True
- except:
- raise Exception, 'Needs python-utmp module'
+ def check(self):
+ try:
+ global utmp
+ import utmp
+ return True
+ except:
+ raise Exception, 'Needs python-utmp module'
- def extract(self):
- for name in self.vars: self.val[name] = 0
- for u in utmp.UtmpRecord():
-# print '# type:%s pid:%s line:%s id:%s user:%s host:%s session:%s' % (i.ut_type, i.ut_pid, i.ut_line, i.ut_id, i.ut_user, i.ut_host, i.ut_session)
- if u.ut_type == utmp.USER_PROCESS:
- self.val['users'] = self.val['users'] + 1
- if u.ut_user == 'root':
- self.val['root'] = self.val['root'] + 1
- self.val['sessions'] = self.val['sessions'] + 1
+ def extract(self):
+ for name in self.vars: self.val[name] = 0
+ for u in utmp.UtmpRecord():
+# print '# type:%s pid:%s line:%s id:%s user:%s host:%s session:%s' % (i.ut_type, i.ut_pid, i.ut_line, i.ut_id, i.ut_user, i.ut_host, i.ut_session)
+ if u.ut_type == utmp.USER_PROCESS:
+ self.val['users'] = self.val['users'] + 1
+ if u.ut_user == 'root':
+ self.val['root'] = self.val['root'] + 1
+ self.val['sessions'] = self.val['sessions'] + 1
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
134 plugins/dstat_vmkhba.py
@@ -13,74 +13,74 @@
# # dstat -M vmkhba -d -D sda,vmhba1
class dstat_vmkhba(dstat):
- def __init__(self):
- self.name = 'vmkhba'
- self.discover = self.discover()
- self.format = ('f', 5, 1024)
- self.nick = ('read', 'writ')
- self.vars = self.vars()
- self.name = self.vars
- self.init(self.vars + ['total'], 2)
+ def __init__(self):
+ self.name = 'vmkhba'
+ self.discover = self.discover()
+ self.format = ('f', 5, 1024)
+ self.nick = ('read', 'writ')
+ self.vars = self.vars()
+ self.name = self.vars
+ self.init(self.vars + ['total'], 2)
- def discover(self, *list):
- # discover will list all vmhba's found.
- # we might want to filter out the unused vmhba's (read stats, compare with ['0', ] * 13)
- ret = []
- try:
- list = os.listdir('/proc/vmware/scsi/')
- except:
- raise Exception, 'Needs VMware ESX'
- for name in list:
- for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines():
- l = line.split()
- if len(l) < 13: continue
- if l[0] == 'cmds': continue
- if l == ['0', ] * 13: continue
- ret.append(name)
- return ret
+ def discover(self, *list):
+ # discover will list all vmhba's found.
+ # we might want to filter out the unused vmhba's (read stats, compare with ['0', ] * 13)
+ ret = []
+ try:
+ list = os.listdir('/proc/vmware/scsi/')
+ except:
+ raise Exception, 'Needs VMware ESX'
+ for name in list:
+ for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines():
+ l = line.split()
+ if len(l) < 13: continue
+ if l[0] == 'cmds': continue
+ if l == ['0', ] * 13: continue
+ ret.append(name)
+ return ret
- def vars(self):
- # vars will take the argument list - when implemented - , use total, or will use discover + total
- ret = []
- if op.disklist:
- list = op.disklist
- #elif not op.full:
- # list = ('total', )
- else:
- list = self.discover
- list.sort()
- for name in list:
- if name in self.discover + ['total']:
- ret.append(name)
- return ret
+ def vars(self):
+ # vars will take the argument list - when implemented - , use total, or will use discover + total
+ ret = []
+ if op.disklist:
+ list = op.disklist
+ #elif not op.full:
+ # list = ('total', )
+ else:
+ list = self.discover
+ list.sort()
+ for name in list:
+ if name in self.discover + ['total']:
+ ret.append(name)
+ return ret
- def check(self):
- info(1, 'The vmkhba module is an EXPERIMENTAL module.')
- ret = True
- try:
- os.listdir('/proc/vmware')
- except:
- raise Exception, 'Needs VMware ESX'
- return ret
+ def check(self):
+ info(1, 'The vmkhba module is an EXPERIMENTAL module.')
+ ret = True
+ try:
+ os.listdir('/proc/vmware')
+ except:
+ raise Exception, 'Needs VMware ESX'
+ return ret
- def extract(self):
- self.cn2['total'] = (0, 0)
- for name in self.vars:
- self.cn2[name] = (0, 0)
- for name in os.listdir('/proc/vmware/scsi/'):
- for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines():
- l = line.split()
- if len(l) < 13: continue
- if l[0] == 'cmds': continue
- if l[2] == '0' and l[4] == '0': continue
- if l == ['0', ] * 13: continue
- self.cn2['total'] = ( self.cn2['total'][0] + long(l[2]), self.cn2['total'][1] + long(l[4]) )
- if name in self.vars and name != 'total':
- self.cn2[name] = ( long(l[2]), long(l[4]) )
- for name in self.cn2.keys():
- self.val[name] = (
- (self.cn2[name][0] - self.cn1[name][0]) * 1024.0 / tick,
- (self.cn2[name][1] - self.cn1[name][1]) * 1024.0 / tick
- )
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ self.cn2['total'] = (0, 0)
+ for name in self.vars:
+ self.cn2[name] = (0, 0)
+ for name in os.listdir('/proc/vmware/scsi/'):
+ for line in dopen('/proc/vmware/scsi/%s/stats' % name).readlines():
+ l = line.split()
+ if len(l) < 13: continue
+ if l[0] == 'cmds': continue
+ if l[2] == '0' and l[4] == '0': continue
+ if l == ['0', ] * 13: continue
+ self.cn2['total'] = ( self.cn2['total'][0] + long(l[2]), self.cn2['total'][1] + long(l[4]) )
+ if name in self.vars and name != 'total':
+ self.cn2[name] = ( long(l[2]), long(l[4]) )
+ for name in self.cn2.keys():
+ self.val[name] = (
+ (self.cn2[name][0] - self.cn1[name][0]) * 1024.0 / tick,
+ (self.cn2[name][1] - self.cn1[name][1]) * 1024.0 / tick
+ )
+ if step == op.delay:
+ self.cn1.update(self.cn2)
View
162 plugins/dstat_vmkint.py
@@ -12,92 +12,92 @@
# Look at /proc/vmware/interrupts to see which interrupt is linked to which function
class dstat_vmkint(dstat):
- def __init__(self):
- self.name = 'vmkint'
- self.open('/proc/vmware/interrupts')
- self.discover = self.discover()
- self.format = ('d', 4, 1000)
-# self.intmap = self.intmap()
- self.vars = self.vars()
- self.nick = self.vars
- self.init(self.vars, 1)
+ def __init__(self):
+ self.name = 'vmkint'
+ self.open('/proc/vmware/interrupts')
+ self.discover = self.discover()
+ self.format = ('d', 4, 1000)
+# self.intmap = self.intmap()
+ self.vars = self.vars()
+ self.nick = self.vars
+ self.init(self.vars, 1)
-# def intmap(self):
-# ret = {}
-# for line in dopen('/proc/vmware/interrupts').readlines():
-# l = line.split()
-# if len(l) <= self.vmkcpunr: continue
-# l1 = l[0].split(':')[0]
-# l2 = ' '.join(l[vmkcpunr()+1:]).split(',')
-# ret[l1] = l1
-# for name in l2:
-# ret[name.strip().lower()] = l1
-# return ret
+# def intmap(self):
+# ret = {}
+# for line in dopen('/proc/vmware/interrupts').readlines():
+# l = line.split()
+# if len(l) <= self.vmkcpunr: continue
+# l1 = l[0].split(':')[0]
+# l2 = ' '.join(l[vmkcpunr()+1:]).split(',')
+# ret[l1] = l1
+# for name in l2:
+# ret[name.strip().lower()] = l1
+# return ret
- def vmkcpunr(self):
- #the service console sees only one CPU, so cpunr == 1, only the vmkernel sees all CPUs
- ret = []
- # default cpu number is 2
- ret = 2
- self.fd[0].seek(0)
- for line in self.fd[0].readlines():
- l = line.split()
- if l[0] == 'Vector':
- ret = int( int( l[-1] ) + 1 )
- return ret
+ def vmkcpunr(self):
+ #the service console sees only one CPU, so cpunr == 1, only the vmkernel sees all CPUs
+ ret = []
+ # default cpu number is 2
+ ret = 2
+ self.fd[0].seek(0)
+ for line in self.fd[0].readlines():
+ l = line.split()
+ if l[0] == 'Vector':
+ ret = int( int( l[-1] ) + 1 )
+ return ret
- def discover(self):
- #interrupt names are not decimal numbers, but rather hexadecimal numbers like 0x7e
- ret = []
- self.fd[0].seek(0)
- for line in self.fd[0].readlines():
- l = line.split()
- if l[0] == 'Vector': continue
- if len(l) < self.vmkcpunr()+1: continue
- name = l[0].split(':')[0]
- amount = 0
- for i in l[1:1+self.vmkcpunr()]:
- amount = amount + long(i)
- if amount > 20: ret.append(str(name))
- return ret
+ def discover(self):
+ #interrupt names are not decimal numbers, but rather hexadecimal numbers like 0x7e
+ ret = []
+ self.fd[0].seek(0)
+ for line in self.fd[0].readlines():
+ l = line.split()
+ if l[0] == 'Vector': continue
+ if len(l) < self.vmkcpunr()+1: continue
+ name = l[0].split(':')[0]
+ amount = 0
+ for i in l[1:1+self.vmkcpunr()]:
+ amount = amount + long(i)
+ if amount > 20: ret.append(str(name))
+ return ret
- def vars(self):
- ret = []
- if op.intlist:
- list = op.intlist
- else:
- list = self.discover
-# len(list) > 5: list = list[-5:]
- for name in list:
- if name in self.discover:
- ret.append(name)
-# elif name.lower() in self.intmap.keys():
-# ret.append(self.intmap[name.lower()])
- return ret
+ def vars(self):
+ ret = []
+ if op.intlist:
+ list = op.intlist
+ else:
+ list = self.discover
+# len(list) > 5: list = list[-5:]
+ for name in list:
+ if name in self.discover:
+ ret.append(name)
+# elif name.lower() in self.intmap.keys():
+# ret.append(self.intmap[name.lower()])
+ return ret
- def check(self):
- info(1, 'The vmkint module is an EXPERIMENTAL module.')
- ret = True
- try:
- os.listdir('/proc/vmware')
- except:
- ret = False
- raise Exception, 'Needs VMware ESX'
- return ret
+ def check(self):
+ info(1, 'The vmkint module is an EXPERIMENTAL module.')
+ ret = True
+ try:
+ os.listdir('/proc/vmware')
+ except:
+ ret = False
+ raise Exception, 'Needs VMware ESX'
+ return ret
- def extract(self):
- self.fd[0].seek(0)
- for line in self.fd[0].readlines():
- l = line.split()
- if len(l) < self.vmkcpunr()+1: continue
- name = l[0].split(':')[0]
- if name in self.vars:
- self.cn2[name] = 0
- for i in l[1:1+self.vmkcpunr()]:
- self.cn2[name] = self.cn2[name] + long(i)
- for name in self.cn2.keys():
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ self.fd[0].seek(0)
+ for line in self.fd[0].readlines():
+ l = line.split()
+ if len(l) < self.vmkcpunr()+1: continue
+ name = l[0].split(':')[0]
+ if name in self.vars:
+ self.cn2[name] = 0
+ for i in l[1:1+self.vmkcpunr()]:
+ self.cn2[name] = self.cn2[name] + long(i)
+ for name in self.cn2.keys():
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
# vim:ts=4:sw=4
View
100 plugins/dstat_vzcpu.py
@@ -7,58 +7,58 @@
#301 27188 0 7896 152899846 853267000490282 0 427043845492614 701812592320 0 0 0
class dstat_vzcpu(dstat):
- def __init__(self):
- self.format = ('p', 3, 34)
- self.open('/proc/vz/vestat')
- self.nick = ('usr', 'sys', 'idl', 'nic')
- self.discover = self.discover()
- self.vars = self.vars()
- self.name = self.name()
- self.init(self.vars + ['total'], 4)
- info(1, 'Module dstat_vzcpu is still experimental.')
+ def __init__(self):
+ self.format = ('p', 3, 34)
+ self.open('/proc/vz/vestat')
+ self.nick = ('usr', 'sys', 'idl', 'nic')
+ self.discover = self.discover()
+ self.vars = self.vars()
+ self.name = self.name()
+ self.init(self.vars + ['total'], 4)
+ info(1, 'Module dstat_vzcpu is still experimental.')
- def discover(self, *list):
- ret = []
- for line in self.readlines():
- l = line.split()
- if len(l) < 6 or l[0] == 'VEID': continue
- ret.append(l[0])
- ret.sort()
- for item in list: ret.append(item)
- return ret
+ def discover(self, *list):
+ ret = []
+ for line in self.readlines():
+ l = line.split()
+ if len(l) < 6 or l[0] == 'VEID': continue
+ ret.append(l[0])
+ ret.sort()
+ for item in list: ret.append(item)
+ return ret
- def name(self):
- ret = []
- for name in self.vars:
- if name == 'total':
- ret.append('total ve usage')
- else:
- ret.append('ve ' + name + ' usage')
- return ret
+ def name(self):
+ ret = []
+ for name in self.vars:
+ if name == 'total':
+ ret.append('total ve usage')
+ else:
+ ret.append('ve ' + name + ' usage')
+ return ret
- def vars(self):
- ret = []
- if not op.full:
- list = ('total', )
- else:
- list = self.discover
- for name in list:
- if name in self.discover + ['total']:
- ret.append(name)
- return ret
+ def vars(self):
+ ret = []
+ if not op.full:
+ list = ('total', )
+ else:
+ list = self.discover
+ for name in list:
+ if name in self.discover + ['total']:
+ ret.append(name)
+ return ret
- def extract(self):
- self.cn2['total'] = [0, 0, 0, 0]
- for line in self.readlines():
- l = line.split()
- if len(l) < 6 or l[0] == 'VEID': continue
- name = l[0]
- self.cn2[name] = ( long(l[1]), long(l[3]), long(l[4]) - long(l[1]) - long(l[2]) - long(l[3]), long(l[2]) )
- self.cn2['total'] = ( self.cn2['total'][0] + long(l[1]), self.cn2['total'][1] + long(l[3]), self.cn2['total'][2] + long(l[4]) - long(l[1]) - long(l[2]) - long(l[3]), self.cn2['total'][3] + long(l[2]) )
- for name in self.vars:
- for i in range(4):
- self.val[name][i] = 100.0 * (self.cn2[name][i] - self.cn1[name][i]) / (sum(self.cn2[name]) - sum(self.cn1[name]))
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ self.cn2['total'] = [0, 0, 0, 0]
+ for line in self.readlines():
+ l = line.split()
+ if len(l) < 6 or l[0] == 'VEID': continue
+ name = l[0]
+ self.cn2[name] = ( long(l[1]), long(l[3]), long(l[4]) - long(l[1]) - long(l[2]) - long(l[3]), long(l[2]) )
+ self.cn2['total'] = ( self.cn2['total'][0] + long(l[1]), self.cn2['total'][1] + long(l[3]), self.cn2['total'][2] + long(l[4]) - long(l[1]) - long(l[2]) - long(l[3]), self.cn2['total'][3] + long(l[2]) )
+ for name in self.vars:
+ for i in range(4):
+ self.val[name][i] = 100.0 * (self.cn2[name][i] - self.cn1[name][i]) / (sum(self.cn2[name]) - sum(self.cn1[name]))
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
118 plugins/dstat_vzubc.py
@@ -2,67 +2,67 @@
import string
class dstat_vzubc(dstat):
- def __init__(self):
- self.format = ('d', 5, 1000)
- self.open('/proc/user_beancounters')
- self.nick = ('fcnt', )
- self.discover = self.discover()
- self.vars = self.vars()
- self.name = self.name()
- self.init(self.vars + ['total'], 1)
- info(1, 'Module dstat_vzubc is still experimental.')
+ def __init__(self):
+ self.format = ('d', 5, 1000)
+ self.open('/proc/user_beancounters')
+ self.nick = ('fcnt', )
+ self.discover = self.discover()
+ self.vars = self.vars()
+ self.name = self.name()
+ self.init(self.vars + ['total'], 1)
+ info(1, 'Module dstat_vzubc is still experimental.')
- def discover(self, *list):
- ret = []
- for line in self.readlines():
- l = line.split()
- if len(l) < 7 or l[0] in ('uid', '0:'): continue
- ret.append(l[0][0:-1])
- ret.sort()
- for item in list: ret.append(item)
- return ret
+ def discover(self, *list):
+ ret = []
+ for line in self.readlines():
+ l = line.split()
+ if len(l) < 7 or l[0] in ('uid', '0:'): continue
+ ret.append(l[0][0:-1])
+ ret.sort()
+ for item in list: ret.append(item)
+ return ret
- def name(self):
- ret = []
- for name in self.vars:
- if name == 'total':
- ret.append('total failcnt')
- else:
- ret.append(name)
- return ret
+ def name(self):
+ ret = []
+ for name in self.vars:
+ if name == 'total':
+ ret.append('total failcnt')
+ else:
+ ret.append(name)
+ return ret
- def vars(self):
- ret = []
- if not op.full:
- list = ('total', )
- else:
- list = self.discover
- for name in list:
- if name in self.discover + ['total']:
- ret.append(name)
- return ret
+ def vars(self):
+ ret = []
+ if not op.full:
+ list = ('total', )
+ else:
+ list = self.discover
+ for name in list:
+ if name in self.discover + ['total']:
+ ret.append(name)
+ return ret
- def extract(self):
- for name in self.vars + ['total']:
- self.cn2[name] = 0
- for line in self.readlines():
- l = line.split()
- if len(l) < 6 or l[0] == 'uid':
- continue
- elif len(l) == 7:
- name = l[0][0:-1]
- if name in self.vars:
- self.cn2[name] = self.cn2[name] + long(l[6])
- self.cn2['total'] = self.cn2['total'] + long(l[6])
- elif name == '0':
- continue
- else:
- if name in self.vars:
- self.cn2[name] = self.cn2[name] + long(l[5])
- self.cn2['total'] = self.cn2['total'] + long(l[5])
- for name in self.vars:
- self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
- if step == op.delay:
- self.cn1.update(self.cn2)
+ def extract(self):
+ for name in self.vars + ['total']:
+ self.cn2[name] = 0
+ for line in self.readlines():
+ l = line.split()
+ if len(l) < 6 or l[0] == 'uid':
+ continue
+ elif len(l) == 7:
+ name = l[0][0:-1]
+ if name in self.vars:
+ self.cn2[name] = self.cn2[name] + long(l[6])
+ self.cn2['total'] = self.cn2['total'] + long(l[6])
+ elif name == '0':
+ continue
+ else:
+ if name in self.vars:
+ self.cn2[name] = self.cn2[name] + long(l[5])
+ self.cn2['total'] = self.cn2['total'] + long(l[5])
+ for name in self.vars:
+ self.val[name] = (self.cn2[name] - self.cn1[name]) * 1.0 / tick
+ if step == op.delay:
+ self.cn1.update(self.cn2)
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et
View
50 plugins/dstat_wifi.py
@@ -2,31 +2,31 @@
from pythonwifi import iwlibs
class dstat_wifi(dstat):
- def __init__(self):
- self.name = 'wifi'
- self.format = ('d', 3, 33)
- self.check()
- self.vars = iwlibs.getNICnames()
- self.name = self.vars
- self.nick = ('lnk', 's/n')
- self.init(self.vars, 2)
+ def __init__(self):
+ self.name = 'wifi'
+ self.format = ('d', 3, 33)
+ self.check()
+ self.vars = iwlibs.getNICnames()
+ self.name = self.vars
+ self.nick = ('lnk', 's/n')
+ self.init(self.vars, 2)
- def check(self):
- global iwlibs
- try:
- from pythonwifi import iwlibs
- except:
- raise Exception, 'Needs python-wifi module'
- return True
+ def check(self):
+ global iwlibs
+ try:
+ from pythonwifi import iwlibs
+ except:
+ raise Exception, 'Needs python-wifi module'
+ return True
- def extract(self):
- for name in self.vars:
- wifi = iwlibs.Wireless(name)
- stat, qual, discard, missed_beacon = wifi.getStatistics()
-# print qual.quality, qual.signallevel, qual.noiselevel
- if qual.quality == 0 or qual.signallevel == -101 or qual.noiselevel == -101 or qual.signallevel == -256 or qual.noiselevel == -256:
- self.val[name] = ( -1, -1 )
- else:
- self.val[name] = ( qual.quality, qual.signallevel * 100 / qual.noiselevel )
+ def extract(self):
+ for name in self.vars:
+ wifi = iwlibs.Wireless(name)
+ stat, qual, discard, missed_beacon = wifi.getStatistics()
+# print qual.quality, qual.signallevel, qual.noiselevel
+ if qual.quality == 0 or qual.signallevel == -101 or qual.noiselevel == -101 or qual.signallevel == -256 or qual.noiselevel == -256:
+ self.val[name] = ( -1, -1 )
+ else:
+ self.val[name] = ( qual.quality, qual.signallevel * 100 / qual.noiselevel )
-# vim:ts=4:sw=4
+# vim:ts=4:sw=4:et

0 comments on commit 57b2b90

Please sign in to comment.
Something went wrong with that request. Please try again.