Commit e811b5eb authored by ueli heuer's avatar ueli heuer 👾
Browse files

add Module esxi_cpu to monitor the CPU usage of an esxi_host.

Probably it works with all host supporting the hrProcessorLoad OID in there SNMP
parent aa5c166a
#
# Copyright (C) 2019 .2019 Ueli Heuer ueli@dvgtool.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
# esxi_cpu ($host_id,$community,$dummy) ;
# TODO: add support for SNMP-values as stored within the DVGtool Database
sub esxi_cpu ($$) {
my ($target,$community,$dummy) = @_;
my ($answer, $error);
my ($res, $out,$packet_in,$packet_out,$macaddress,$mac,$a,$b,$c,$d,$pint_id,$lint_id,$snmp_params);
# $snmp_params=get_snmpparameter();
#$SNMP_Session::suppress_warnings = 2 ;
$res = (@answer, $error) = snmpwalk(
hosts => $target,
snmp => { -version => '2c',
-timeout => 1,
-retries => 5,
-community => $community,
},
oids => { ProccessLoad => '1.3.6.1.2.1.25.3.3.1.2', }
);
die "[ERROR] $error\n" unless @answer;
$value = $answer[0]{$target}{'ProccessLoad'};
$sum = $n = 0;
foreach $num ( values %{$value}) {
$sum += $num;
$n++;
}
$avg = $sum/$n;
return ($avg);
}
$esxi_cpu_mod = 1;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment