Permalink
Browse files

Added VMware ESX dstat_vmknic plugin

  • Loading branch information...
dagwieers committed Jan 19, 2008
1 parent 51e3454 commit 4caa3b5c9f69f54c33bb8538cf3087222d7120b8
Showing with 88 additions and 4 deletions.
  1. +1 −0 ChangeLog
  2. +4 −4 plugins/dstat_cpufreq.py
  3. +83 −0 plugins/dstat_vmknic.py
View
@@ -18,6 +18,7 @@
- Added external dstat_mysql5_* plugins (Frederic Descamps)
- Reinstated the use of -D md0 which got lost (Peter Rabbitson)
- Improvement to cpufreq module for SMP systems (Bert de Bruijn)
+- Added VMware ESX dstat_vmknic plugin (Bert de Bruijn)
* 0.6.6 - Unemployed - released 28/04/2007
- Removed SwapCached from the Cached counter (Dbt 418326, Peter Rabbitson)
View
@@ -13,12 +13,12 @@ def __init__(self):
self.name = 'frequency'
self.format = ('p', 4, 34)
# self.vars = os.listdir('/sys/devices/system/cpu/')
- self.vars = []
- for name in glob.glob('/sys/devices/system/cpu/cpu?'):
- self.vars.append(os.path.basename(name))
# self.nick = [string.lower(name) for name in self.vars]
+ self.vars = []
self.nick = []
- for name in self.vars:
+ for name in glob.glob('/sys/devices/system/cpu/cpu[0-9]*'):
+ name = os.path.basename(name)
+ self.vars.append(name)
self.nick.append(string.lower(name))
self.init(self.vars, 1)
View
@@ -0,0 +1,83 @@
+### VMware ESX kernel vmknic stats
+### Displays VMkernel port 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 -N argument.
+# EXAMPLES:
+# # dstat -M vmknic -N vmk1
+# You can even combine the Linux and VMkernel network stats (just don't just "total").
+# # dstat -M vmknic -n -N vmk0,vswif0
+# NB Data comes from /proc/vmware/net/tcpip/ifconfig
+
+class dstat_vmknic(dstat):
+ def __init__(self):
+ self.name = 'vmknic'
+ self.format = ('f', 5, 1024)
+ self.open('/proc/vmware/net/tcpip/ifconfig')
+ self.nick = ('recv', 'send')
+ self.discover = self.discover()
+ self.vars = self.vars()
+ self.name = ['net/'+name for name in self.vars]
+ self.init(self.vars + ['total',], 2)
+
+ def discover(self, *list):
+ ret = []
+ for line in self.fd[0].readlines():
+ l = line.replace(' /','/').split()
+ if len(l) != 12: continue
+ if l[2][:5] == '<Link': continue
+ if ','.join(l) == 'Name,Mtu/TSO,Network,Address,Ipkts,Ierrs,Ibytes,Opkts,Oerrs,Obytes,Coll,Time': continue
+ if l[0] == 'lo0': continue
+ if l[0] == 'Usage:': continue
+ ret.append(l[0])
+ ret.sort()
+ for item in list: ret.append(item)
+ return ret
+
+ def vars(self):
+ ret = []
+ if op.netlist:
+ list = op.netlist
+ 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 vmknic 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.cn2['total'] = [0, 0]
+ for line in self.readlines():
+ l = line.replace(' /','/').split()
+ if len(l) != 12: continue
+ if l[2][:5] == '<Link': continue
+ if ','.join(l) == 'Name,Mtu/TSO,Network,Address,Ipkts,Ierrs,Ibytes,Opkts,Oerrs,Obytes,Coll,Time': continue
+ if l[0] == 'Usage:': continue
+ name = l[0]
+ if name in self.vars:
+ self.cn2[name] = ( long(l[6]), long(l[9]) )
+ if name != 'lo0':
+ self.cn2['total'] = ( self.cn2['total'][0] + long(l[6]), self.cn2['total'][1] + long(l[9]) )
+ if update:
+ for name in self.cn2.keys():
+ self.val[name] = (
+ (self.cn2[name][0] - self.cn1[name][0]) * 1.0 / tick,
+ (self.cn2[name][1] - self.cn1[name][1]) * 1.0 / tick,
+ )
+ if step == op.delay:
+ self.cn1.update(self.cn2)
+
+# vim:ts=4:sw=4

0 comments on commit 4caa3b5

Please sign in to comment.