mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 07:34:35 +02:00
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:
parent
6319b60f16
commit
f45d669662
@ -106,8 +106,6 @@ $name =~ s/\.pl.*//g;
|
|||||||
|
|
||||||
# Plugin snmp requests
|
# Plugin snmp requests
|
||||||
|
|
||||||
my $OID_CPU = "1.3.6.1.2.1.25.3.3.1.2";
|
|
||||||
|
|
||||||
my ($session, $error);
|
my ($session, $error);
|
||||||
if ($snmp eq "1" || $snmp eq "2") {
|
if ($snmp eq "1" || $snmp eq "2") {
|
||||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
($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
|
# Get all datas
|
||||||
my $result = $session->get_table(Baseoid => $OID_CPU);
|
my $result = $session->get_table(Baseoid => $OID_CPU);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
@ -160,7 +184,7 @@ if ($opt_w <= $cpu) {
|
|||||||
$status = "CRITICAL";
|
$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++){
|
for ($i = 0; defined($cpulist[$i]); $i++){
|
||||||
$str .= " cpu$i=".$cpulist[$i]."%";
|
$str .= " cpu$i=".$cpulist[$i]."%";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user