- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
#!/usr/bin/perl -w
# ESXi host CPU/memory plugin for Munin by Niels Engelen
# http://www.foonet.be
use strict;
use warnings;
use VMware::VIRuntime;
use VMware::VILib;
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $esxihost = basename($0);
$esxihost =~ s/esxi\_cpu\_mem\_//;
my $username = Opts::set_option ('username', $ENV{'username'});
my $password = Opts::set_option ('password', $ENV{'password'});
my $url = Opts::set_option ('url', "https://$esxihost/sdk/webService");
my ($host_info);
if ( exists $ARGV[0] and $ARGV[0] eq "config" ) {
print "graph_title ESXi CPU/Memory ".$esxihost." \n";
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100 \n";
print "graph_vlabel % \n";
print "graph_category ESXi CPU/Memory\n";
print "graph_scale no\n";
print "mem.label MEM used\n";
print "mem.draw AREA\n";
print "cpu.label CPU used\n";
exit 0;
} else {
Opts::parse();
Opts::validate();
Util::connect();
$host_info = Vim::find_entity_view(view_type => 'HostSystem', properties => ['summary.hardware', 'summary.quickStats'], filter => {'summary.runtime.connectionState' => 'connected'});
&get_host_mem_info($host_info);
&get_host_cpu_info($host_info);
Util::disconnect();
exit 0;
}
sub get_host_mem_info {
if ($host_info) {
my $percentMemoryUsed = ($host_info->{'summary.quickStats'}->overallMemoryUsage * 1024 * 1024 / $host_info->{'summary.hardware'}->memorySize) * 100;
printf "mem.value %.2f\n",$percentMemoryUsed;
}
}
sub get_host_cpu_info {
if ($host_info) {
my $percentCpuUsed = ($host_info->{'summary.quickStats'}->overallCpuUsage / ($host_info->{'summary.hardware'}->cpuMhz * $host_info->{'summary.hardware'}->numCpuCores)) * 100;
printf "cpu.value %.2f\n",$percentCpuUsed;
}
}
guest8 06.10.2018 23:58 # −999
roman-kashitsyn 07.10.2018 00:05 # 0
guest8 07.10.2018 01:56 # −999
guest8 07.10.2018 09:37 # −999
guest8 06.06.2019 21:39 # −999
miheich 06.06.2019 22:04 # 0
guest8 06.06.2019 22:14 # −999
guest8 04.11.2018 03:44 # −999
guest8 04.11.2018 03:45 # −999
guest8 04.11.2018 12:52 # −999
guest8 14.11.2019 03:35 # −999
3_14ton 15.11.2019 19:18 # +1
guest8 15.11.2019 19:24 # −999
XYPO3BO3 16.11.2019 17:41 # 0