From 4753be966cc2b5c0bdc934ae0ac00a701eb39388 Mon Sep 17 00:00:00 2001 From: Julien Mathis Date: Tue, 8 Jan 2008 11:26:59 +0000 Subject: [PATCH] disable UTF8 git-svn-id: http://svn.centreon.com/trunk/plugins-2.x@3717 6bcd3966-0018-0410-8128-fd23d134de7e --- .../src/check_centreon_snmp_remote_storage | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/centreon-plugins/src/check_centreon_snmp_remote_storage b/centreon-plugins/src/check_centreon_snmp_remote_storage index e2f772e28..df3c75e25 100644 --- a/centreon-plugins/src/check_centreon_snmp_remote_storage +++ b/centreon-plugins/src/check_centreon_snmp_remote_storage @@ -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 {