Permalink
Browse files

Added three new VMware guest plugins

  • Loading branch information...
1 parent f03b360 commit cbf1e97c309b0192378c20c75b81e3f16e323c9f @bertdb bertdb committed with Dec 9, 2013
Showing with 108 additions and 0 deletions.
  1. +38 −0 plugins/dstat_vm_cpu.py
  2. +33 −0 plugins/dstat_vm_mem.py
  3. +37 −0 plugins/dstat_vm_mem_adv.py
View
@@ -0,0 +1,38 @@
+### Author: Bert de Bruijn <bert+dstat$debruijn,be>
+
+### VMware cpu stats
+### Displays CPU stats coming from the hypervisor inside VMware VMs.
+### The vmGuestLib API from VMware Tools needs to be installed
+
+class dstat_plugin(dstat):
+ def __init__(self):
+ self.name = 'vm cpu'
+ self.vars = ('used', 'stolen', 'elapsed')
+ self.nick = ('usd', 'stl')
+ self.type = 'p'
+ self.width = 3
+ self.scale = 100
+ self.cpunr = getcpunr()
+
+ def check(self):
+ try:
+ global vmguestlib
+ import vmguestlib
+
+ self.gl = vmguestlib.VMGuestLib()
+ except:
+ raise Exception, 'Needs python-vmguestlib module'
+
+ def extract(self):
+ self.gl.UpdateInfo()
+ self.set2['elapsed'] = self.gl.GetElapsedMs()
+ self.set2['stolen'] = self.gl.GetCpuStolenMs()
+ self.set2['used'] = self.gl.GetCpuUsedMs()
+
+ for name in ('stolen', 'used'):
+ self.val[name] = (self.set2[name] - self.set1[name]) * 100 / (self.set2['elapsed'] - self.set1['elapsed']) / self.cpunr
+
+ if step == op.delay:
+ self.set1.update(self.set2)
+
+# vim:ts=4:sw=4
View
@@ -0,0 +1,33 @@
+### Author: Bert de Bruijn <bert+dstat$debruijn,be>
+
+### VMware memory stats
+### Displays memory stats coming from the hypervisor inside VMware VMs.
+### The vmGuestLib API from VMware Tools needs to be installed
+
+class dstat_plugin(dstat):
+ def __init__(self):
+ self.name = 'vmware memory'
+ self.vars = ('active', 'ballooned', 'mapped', 'swapped', 'used')
+ self.nick = ('active', 'balln', 'mappd', 'swapd', 'used')
+ self.type = 'd'
+ self.width = 5
+ self.scale = 1024
+
+ def check(self):
+ try:
+ global vmguestlib
+ import vmguestlib
+
+ self.gl = vmguestlib.VMGuestLib()
+ except:
+ raise Exception, 'Needs python-vmguestlib module'
+
+ def extract(self):
+ self.gl.UpdateInfo()
+ self.val['active'] = self.gl.GetMemActiveMB() * 1024 ** 2
+ self.val['ballooned'] = self.gl.GetMemBalloonedMB() * 1024 ** 2
+ self.val['mapped'] = self.gl.GetMemMappedMB() * 1024 ** 2
+ self.val['swapped'] = self.gl.GetMemSwappedMB() * 1024 ** 2
+ self.val['used'] = self.gl.GetMemUsedMB() * 1024 ** 2
+
+# vim:ts=4:sw=4
@@ -0,0 +1,37 @@
+### Author: Bert de Bruijn <bert+dstat$debruijn,be>
+
+### VMware advanced memory stats
+### Displays memory stats coming from the hypervisor inside VMware VMs.
+### The vmGuestLib API from VMware Tools needs to be installed
+
+class dstat_plugin(dstat):
+ def __init__(self):
+ self.name = 'memory'
+ self.vars = ('active', 'ballooned', 'mapped', 'overhead', 'saved', 'shared', 'swapped', 'targetsize', 'used')
+ self.nick = ('active', 'balln', 'mappd', 'ovrhd', 'saved', 'shard', 'swapd', 'targt', 'used')
+ self.type = 'd'
+ self.width = 5
+ self.scale = 1024
+
+ def check(self):
+ try:
+ global vmguestlib
+ import vmguestlib
+
+ self.gl = vmguestlib.VMGuestLib()
+ except:
+ raise Exception, 'Needs python-vmguestlib module'
+
+ def extract(self):
+ self.gl.UpdateInfo()
+ self.val['active'] = self.gl.GetMemActiveMB() * 1024 ** 2
+ self.val['ballooned'] = self.gl.GetMemBalloonedMB() * 1024 ** 2
+ self.val['mapped'] = self.gl.GetMemMappedMB() * 1024 ** 2
+ self.val['overhead'] = self.gl.GetMemOverheadMB() * 1024 ** 2
+ self.val['saved'] = self.gl.GetMemSharedSavedMB() * 1024 ** 2
+ self.val['shared'] = self.gl.GetMemSharedMB() * 1024 ** 2
+ self.val['swapped'] = self.gl.GetMemSwappedMB() * 1024 ** 2
+ self.val['targetsize'] = self.gl.GetMemTargetSizeMB() * 1024 ** 2
+ self.val['used'] = self.gl.GetMemUsedMB() * 1024 ** 2
+
+# vim:ts=4:sw=4

0 comments on commit cbf1e97

Please sign in to comment.