From e44e6facedae647d5c3012e7d20a616c35537888 Mon Sep 17 00:00:00 2001 From: Nicolas Cordier Date: Wed, 27 May 2009 15:25:12 +0000 Subject: [PATCH] add -P (SNMP port) option for check_centreon_snmp_memory git-svn-id: http://svn.centreon.com/trunk/plugins-2.x@8226 6bcd3966-0018-0410-8128-fd23d134de7e --- centreon-plugins/src/check_centreon_snmp_memory | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/src/check_centreon_snmp_memory b/centreon-plugins/src/check_centreon_snmp_memory index 91dd0347d..e9b94fba5 100644 --- a/centreon-plugins/src/check_centreon_snmp_memory +++ b/centreon-plugins/src/check_centreon_snmp_memory @@ -57,7 +57,7 @@ if (eval "require centreon" ) { use vars qw($PROGNAME); use Getopt::Long; -use vars qw($opt_V $opt_h $opt_g $opt_v $opt_C $opt_w $opt_c $opt_s $opt_H @test); +use vars qw($opt_V $opt_h $opt_g $opt_v $opt_C $opt_w $opt_c $opt_s $opt_H $opt_P @test); my $pathtorrdbase = $centreon{GLOBAL}{DIR_RRDTOOL}; ## @@ -76,6 +76,7 @@ GetOptions ("h" => \$opt_h, "help" => \$opt_h, "V" => \$opt_V, "version" => \$opt_V, "v=s" => \$opt_v, "snmp=s" => \$opt_v, + "P=s" => \$opt_P, "snmp-port=s" => \$opt_P, "C=s" => \$opt_C, "community=s" => \$opt_C, "w=s" => \$opt_w, "warning=s" => \$opt_w, "c=s" => \$opt_c, "critical=s" => \$opt_c, @@ -88,6 +89,10 @@ if ($opt_V) { exit $ERRORS{'OK'}; } +if (!defined($opt_P)) { + $opt_P = 161; +} + if ($opt_h) { print_help(); exit $ERRORS{'OK'}; @@ -132,7 +137,7 @@ my $name = $0; # create a SNMP session -my ( $session, $error ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp); +my ( $session, $error ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp, -port => $opt_P); if ( !defined($session) ) { print("CRITICAL: SNMP Session : $error"); exit $ERRORS{'CRITICAL'}; @@ -250,6 +255,7 @@ sub print_usage () { print " used with SNMP v1 and v2c\n"; print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; print " 2 for SNMP v2c\n"; + print " -P (--snmp-port) SNMP port (default: 161)\n"; print " -V (--version) Plugin version\n"; print " -h (--help) usage help\n"; print " -c (--critical) percentage of memory used at which a critical message will be generated\n";