disable UTF8
git-svn-id: http://svn.centreon.com/trunk/plugins-2.x@3717 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
parent
f59d15ccc3
commit
4753be966c
|
@ -28,8 +28,7 @@ use strict;
|
|||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "/usr/local/nagios/libexec";
|
||||
#use lib "@NAGIOS_PLUGINS@";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
|
@ -158,24 +157,26 @@ my $OID_hrStorageUsed = $centreon{MIB2}{HR_STORAGE_USED};
|
|||
# create a SNMP session
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
} elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
} elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
$session->translate(Net::SNMP->TRANSLATE_NONE) if (defined($session));
|
||||
|
||||
|
||||
#getting partition using its name instead of its oid index
|
||||
if ($opt_n) {
|
||||
|
@ -209,8 +210,9 @@ if ($opt_s) {
|
|||
# Get description table
|
||||
my $result = $session->get_table(
|
||||
Baseoid => $OID_hrStorageDescr
|
||||
if (!defined($result)) {
|
||||
);
|
||||
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: hrStorageDescr Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
|
@ -219,11 +221,12 @@ if ($opt_s) {
|
|||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
my $index = pop (@oid_list) ;
|
||||
print "hrStorage $index :: @$result{$key}\n";
|
||||
print "hrStorage $index :: $$result{$key}\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
|
||||
my $result = $session->get_request(
|
||||
-varbindlist => [$OID_hrStorageDescr.".".$partition ,
|
||||
$OID_hrStorageAllocationUnits.".".$partition ,
|
||||
|
@ -300,7 +303,7 @@ if (($Size =~ /([0-9]+)/) && ($AllocationUnits =~ /([0-9]+)/)){
|
|||
my $size_o = $Used * 1073741824;
|
||||
my $warn = $opt_w * $size_o;
|
||||
my $crit = $opt_c * $size_o;
|
||||
print "|size=".$lastTot."o used=".$size_o.";".$warn.";".$crit;
|
||||
print "|size=".$lastTot."o used=".$size_o."o;".$warn.";".$crit;
|
||||
print "\n";
|
||||
exit $return_code;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue