apply patch from bug #55

git-svn-id: http://svn.centreon.com/trunk/plugins-2.x@5536 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
Julien Mathis 2008-07-08 09:04:38 +00:00
parent 3bb21f5e2e
commit 358e783f8e
1 changed files with 27 additions and 3 deletions

View File

@ -106,8 +106,6 @@ $name =~ s/\.pl.*//g;
# Plugin snmp requests
my $OID_CPU = "1.3.6.1.2.1.25.3.3.1.2";
my ($session, $error);
if ($snmp eq "1" || $snmp eq "2") {
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
@ -129,6 +127,32 @@ if ($snmp eq "1" || $snmp eq "2") {
}
}
sub get_netsnmp_version (){
my $sess = $_[0];
my $OID_VERSION = "1.3.6.1.2.1.25.6.3.1.2";
my $result = $sess->get_table(Baseoid => $OID_VERSION);
if (!defined($result)) {
printf("ERROR when getting CPU percentage use values : ProcessorLoad Table : %s.\n", $session->error);
$session->close;
exit $ERRORS{'UNKNOWN'};
}
while ( my ($key, $value) = each(%$result) ) {
if ($value =~ m/net-snmp-5.3.*/) {
return "NetSNMP-5.3"
}
}
return "Other";
}
my $OID_CPU = "";
my $snmpver = get_netsnmp_version($session);
if ( "$snmpver" eq "NetSNMP-5.3" ) {
$OID_CPU = ".1.3.6.1.4.1.2021.11.9";
} else {
$OID_CPU = ".1.3.6.1.2.1.25.3.3.1.2";
}
# Get all datas
my $result = $session->get_table(Baseoid => $OID_CPU);
if (!defined($result)) {
@ -160,7 +184,7 @@ if ($opt_w <= $cpu) {
$status = "CRITICAL";
}
my $str = "Utilisation moyenne du CPU : ".$cpu."%|avg=".$cpu."%";
my $str = "CPU utilization percentage : ".$cpu."%|avg=".$cpu."%";
for ($i = 0; defined($cpulist[$i]); $i++){
$str .= " cpu$i=".$cpulist[$i]."%";
}