Skip to content
Browse files

Added vmware ESX plugins contributed by Bert de Bruijn.

  • Loading branch information...
1 parent 470f67c commit a507c1db803c8b9245f8c6539bbe50f3dfee2093 @dagwieers committed Dec 28, 2006
Showing with 199 additions and 0 deletions.
  1. +3 −0 ChangeLog
  2. +12 −0 dstat
  3. +84 −0 plugins/dstat_vmkhba.py
  4. +100 −0 plugins/dstat_vmkint.py
View
3 ChangeLog
@@ -1,3 +1,6 @@
+* 0.6.5 - ... - released 28/12/2006
+- Added VMware ESX plugins (Bert de Bruijn)
+
* 0.6.4 - Ahoy - released 12/12/2006
- Fixed dstat_clock to use localtime() instead of gmtime()
- Added external plugin dstat_vz for openvz cpu statistics
View
12 dstat
@@ -1718,6 +1718,18 @@ def main():
if term and re.compile('(screen*|xterm*)').match(term):
sys.stdout.write('\033]0;(%s@%s) %s %s\007' % (user, hostname, os.path.basename(sys.argv[0]), ' '.join(op.args)))
+ ### Check background color (rxvt)
+ ### COLORFGBG="15;default;0"
+# if os.environ['COLORFGBG'] and len(os.environ['COLORFGBG'].split(';')) >= 3:
+# l = os.environ['COLORFGBG'].split(';')
+# bg = int(l[2])
+# if bg < 7:
+# print 'Background is dark'
+# else:
+# print 'Background is light'
+# else:
+# print 'Background is unknown, assuming dark.'
+
### Check terminal capabilities
if not sys.stdout.isatty():
op.color = False
View
84 plugins/dstat_vmkhba.py
@@ -0,0 +1,84 @@
+### VMware ESX kernel vmhba stats
+### Displays kernel vmhba statistics on VMware ESX servers
+###
+### Authority: bert+dstat@debruijn.be
+
+# NOTE TO USERS: command-line plugin configuration is not yet possible, so I've
+# "borrowed" the -D argument.
+# EXAMPLES:
+# # dstat -M vmkhba -D vmhba1,vmhba2,total
+# # dstat -M vmkhba -D vmhba0
+# You can even combine the Linux and VMkernel diskstats (but the "total" argument
+# will be used by both).
+# # 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 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 = []
+ list = os.listdir('/proc/vmware/scsi/')
+ 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 check(self):
+ info(1, 'The vmkhba module is an EXPERIMENTAL module.')
+ ret = True
+ try:
+ os.listdir('/proc/vmware')
+ except:
+ ret = False
+ raise Exception, 'Module vmkhba can only run on 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)
View
100 plugins/dstat_vmkint.py
@@ -0,0 +1,100 @@
+### VMware ESX kernel interrupt stats
+### Displays kernel interrupt statistics on VMware ESX servers
+###
+### Authority: bert+dstat@debruijn.be
+
+# NOTE TO USERS: command-line plugin configuration is not yet possible, so I've
+# "borrowed" the -I argument.
+# EXAMPLES:
+# # dstat -M vmkint -I 0x46,0x5a
+# You can even combine the Linux and VMkernel interrupt stats
+# # dstat -M vmkint -i -I 14,0x5a
+# 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.discover = self.discover()
+ self.format = ('d', 4, 1000)
+ self.open('/proc/vmware/interrupts')
+# 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 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
+ for line in dopen('/proc/vmware/interrupts').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 = []
+ for line in dopen('/proc/vmware/interrupts').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 check(self):
+ info(1, 'The vmkint module is an EXPERIMENTAL module.')
+ ret = True
+ try:
+ os.listdir('/proc/vmware')
+ except:
+ ret = False
+ raise Exception, 'Module vmkint can only run on VMware ESX.'
+ return ret
+
+ def extract(self):
+ for line in dopen('/proc/vmware/interrupts').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

0 comments on commit a507c1d

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