Skip to content

Commit

Permalink
Merge pull request #6 from Mattikin/master
Browse files Browse the repository at this point in the history
Added performance metrics for ESXi Host, added thresholds for CPU and Memory usage
  • Loading branch information
Mattikin committed Mar 28, 2015
2 parents ce5f2fe + d180036 commit 6769e2e
Show file tree
Hide file tree
Showing 8 changed files with 598 additions and 265 deletions.
18 changes: 9 additions & 9 deletions ZenPacks/community/VMwareESXiMonitor/ESXiDatastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ def device(self):
def usedSpace(self):
capacity = self.capacity
free = self.freeSpace()
if capacity is not None and free is not None:
return capacity - free
return None
if capacity is None or free is None:
return None
return capacity - free

def freeSpace(self):
free = self.cacheRRDValue('diskFreeSpace')
if free is not None and not isnan(free):
return long(free)
return None
if free is None or isnan(free):
return None
return long(free)

def usedPercent(self):
capacity = self.capacity
used = self.usedSpace()
if capacity is not None and used is not None:
return round(100.0 * used / capacity)
return 'Unknown'
if capacity is None or used is None:
return 'Unknown'
return round(100.0 * used / capacity)

InitializeClass(ESXiDatastore)

12 changes: 6 additions & 6 deletions ZenPacks/community/VMwareESXiMonitor/ESXiVM.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def device(self):

def adminStatus(self):
status = self.cacheRRDValue('adminStatus')
if status is not None and not isnan(status):
return int(status)
return None
if status is None or isnan(status):
return None
return int(status)

def operStatus(self):
status = self.cacheRRDValue('operStatus')
if status is not None and not isnan(status):
return int(status)
return None
if status is None or isnan(status):
return None
return int(status)

InitializeClass(ESXiVM)

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class VMwareDataSource(ZenPackPersistence, RRDDataSource.SimpleRRDDataSource):

sourcetype = 'VMware'
eventClass = Cmd_Fail
parser = 'ZenPacks.community.VMwareESXiMonitor.parsers.vmware'
performanceSource = ''
instance = ''

Expand Down Expand Up @@ -70,7 +69,7 @@ def useZenCommand(self):
def addDataPoints(self):
datastore = ['diskFreeSpace','connectionStatus']
guest = ['memUsage','memOverhead','memConsumed','diskUsage','cpuUsageMin','cpuUsageMax','cpuUsageAvg','cpuUsage','adminStatus','operStatus']
host = ['sysUpTime','memSwapused','memGranted','memActive','diskUsage','cpuUsagemhz','cpuUsage','cpuReservedcapacity','netReceived','netTransmitted','netPacketsRx','netPacketsTx','netDroppedRx','netDroppedTx']
host = ['sysUpTime','memUsage','memSwapused','memGranted','memActive','diskUsage','cpuUsageMin','cpuUsageMax','cpuUsageAvg','cpuUsage','cpuReservedcapacity','netReceived','netTransmitted','netPacketsRx','netPacketsTx','netDroppedRx','netDroppedTx']

if self.id == "VMwareDatastore":
self.performanceSource = "VMwareDatastore"
Expand Down
41 changes: 22 additions & 19 deletions ZenPacks/community/VMwareESXiMonitor/libexec/esxi_monitor.pl
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@
}
else {
my $perfmgr_view = Vim::get_view(mo_ref => Vim::get_service_content()->perfManager, properties => [ 'perfCounter' ]);
my $memUsage = get_info($vm_view, $perfmgr_view, 'mem', 'usage', 'minimum');
my $memOverhead = get_info($vm_view, $perfmgr_view, 'mem', 'overhead', 'minimum');
my $memConsumed = get_info($vm_view, $perfmgr_view, 'mem', 'consumed', 'minimum');
my $diskUsage = get_info($vm_view, $perfmgr_view, 'disk', 'usage', 'average');
my $cpuUsageMin = get_info($vm_view, $perfmgr_view, 'cpu', 'usage', 'minimum');
my $cpuUsageMax = get_info($vm_view, $perfmgr_view, 'cpu', 'usage', 'maximum');
my $cpuUsageAvg = get_info($vm_view, $perfmgr_view, 'cpu', 'usage', 'average');
my $cpuUsage = get_info($vm_view, $perfmgr_view, 'cpu', 'usagemhz', 'average');
my $memUsage = get_info($vm_view, $perfmgr_view, 'mem', 'usage', 'minimum') / 100;
my $memOverhead = get_info($vm_view, $perfmgr_view, 'mem', 'overhead', 'minimum') * 1024;
my $memConsumed = get_info($vm_view, $perfmgr_view, 'mem', 'consumed', 'minimum') * 1024;
my $diskUsage = get_info($vm_view, $perfmgr_view, 'disk', 'usage', 'average') * 1024;
my $cpuUsageMin = get_info($vm_view, $perfmgr_view, 'cpu', 'usage', 'minimum') / 100;
my $cpuUsageMax = get_info($vm_view, $perfmgr_view, 'cpu', 'usage', 'maximum') / 100;
my $cpuUsageAvg = get_info($vm_view, $perfmgr_view, 'cpu', 'usage', 'average') / 100;
my $cpuUsage = get_info($vm_view, $perfmgr_view, 'cpu', 'usagemhz', 'average') * 1000000;

my $overallStatus = $$vm_view[0]->get_property('summary.overallStatus')->val;
my $operStatus = 0;
Expand All @@ -99,26 +99,29 @@
die "Runtime error\n" if (!defined($host_view));
die "Host \"" . $$host_name{"name"} . "\" does not exist\n" if (!@$host_view);
if (uc($$host_view[0]->get_property('runtime.inMaintenanceMode')) eq "TRUE") {
print "hostperf|sysUpTime= memSwapused= memGranted= memActive= diskUsage= cpuUsagemhz= cpuUsage= cpuReservedcapacity= netReceived= netTransmitted= netPacketsRx= netPacketsTx= netDroppedRx= netDroppedTx=\n";
print "hostperf|sysUpTime= memUsage= memSwapused= memGranted= memActive= diskUsage= cpuUsageMin= cpuUsageMax= cpuUsageAvg= cpuUsage= cpuReservedcapacity= netReceived= netTransmitted= netPacketsRx= netPacketsTx= netDroppedRx= netDroppedTx=\n";
}
else {
my $perfmgr_view = Vim::get_view(mo_ref => Vim::get_service_content()->perfManager, properties => [ 'perfCounter' ]);
my $sysUpTime = get_info($host_view, $perfmgr_view, 'sys', 'uptime', 'latest') * 100;
my $memSwapused = get_info($host_view, $perfmgr_view, 'mem', 'swapused', 'maximum');
my $memGranted = get_info($host_view, $perfmgr_view, 'mem', 'granted', 'maximum');
my $memActive = get_info($host_view, $perfmgr_view, 'mem', 'active', 'maximum');
my $diskUsage = get_info($host_view, $perfmgr_view, 'disk', 'usage', 'average');
my $cpuUsagemhz = get_info($host_view, $perfmgr_view, 'cpu', 'usagemhz', 'average');
my $cpuUsage = get_info($host_view, $perfmgr_view, 'cpu', 'usage', 'average');
my $cpuReservedcapacity = get_info($host_view, $perfmgr_view, 'cpu', 'reservedCapacity', 'average');
my $netReceived = get_info($host_view, $perfmgr_view, 'net', 'received', 'average');
my $netTransmitted = get_info($host_view, $perfmgr_view, 'net', 'transmitted', 'average');
my $memUsage = get_info($host_view, $perfmgr_view, 'mem', 'usage', 'minimum') / 100;
my $memSwapused = get_info($host_view, $perfmgr_view, 'mem', 'swapused', 'maximum') * 1024;
my $memGranted = get_info($host_view, $perfmgr_view, 'mem', 'granted', 'maximum') * 1024;
my $memActive = get_info($host_view, $perfmgr_view, 'mem', 'active', 'maximum') * 1024;
my $diskUsage = get_info($host_view, $perfmgr_view, 'disk', 'usage', 'average') * 1024;
my $cpuUsageMin = get_info($host_view, $perfmgr_view, 'cpu', 'usage', 'minimum') / 100;
my $cpuUsageMax = get_info($host_view, $perfmgr_view, 'cpu', 'usage', 'maximum') / 100;
my $cpuUsageAvg = get_info($host_view, $perfmgr_view, 'cpu', 'usage', 'average') / 100;
my $cpuUsage = get_info($host_view, $perfmgr_view, 'cpu', 'usagemhz', 'average') * 1000000;
my $cpuReservedcapacity = get_info($host_view, $perfmgr_view, 'cpu', 'reservedCapacity', 'average') * 1000000;
my $netReceived = get_info($host_view, $perfmgr_view, 'net', 'received', 'average') * 8192;
my $netTransmitted = get_info($host_view, $perfmgr_view, 'net', 'transmitted', 'average') * 8192;
my $netPacketsRx = get_info($host_view, $perfmgr_view, 'net', 'packetsRx', 'summation');
my $netPacketsTx = get_info($host_view, $perfmgr_view, 'net', 'packetsTx', 'summation');
my $netDroppedRx = get_info($host_view, $perfmgr_view, 'net', 'droppedRx', 'summation');
my $netDroppedTx = get_info($host_view, $perfmgr_view, 'net', 'droppedTx', 'summation');

print "hostperf|sysUpTime=".$sysUpTime." memSwapused=".$memSwapused." memGranted=".$memGranted." memActive=".$memActive." diskUsage=".$diskUsage." cpuUsagemhz=".$cpuUsagemhz." cpuUsage=".$cpuUsage." cpuReservedcapacity=".$cpuReservedcapacity." netReceived=".$netReceived." netTransmitted=".$netTransmitted." netPacketsRx=".$netPacketsRx." netPacketsTx=".$netPacketsTx." netDroppedRx=".$netDroppedRx." netDroppedTx=".$netDroppedTx."\n";
print "hostperf|sysUpTime=".$sysUpTime." memUsage=".$memUsage." memSwapused=".$memSwapused." memGranted=".$memGranted." memActive=".$memActive." diskUsage=".$diskUsage." cpuUsageMin=".$cpuUsageMin." cpuUsageMax=".$cpuUsageMax." cpuUsageAvg=".$cpuUsageAvg." cpuUsage=".$cpuUsage." cpuReservedcapacity=".$cpuReservedcapacity." netReceived=".$netReceived." netTransmitted=".$netTransmitted." netPacketsRx=".$netPacketsRx." netPacketsTx=".$netPacketsTx." netDroppedRx=".$netDroppedRx." netDroppedTx=".$netDroppedTx."\n";
}
}
};
Expand Down
Loading

0 comments on commit 6769e2e

Please sign in to comment.