From 588a4d78fbc2e835cce2546715dc8c060793f7a2 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Wed, 28 Aug 2013 15:23:36 +0200 Subject: [PATCH] Fix #4696 --- centreon-plugins/src/Centreon/SNMP/Utils.pm | 8 ++++-- .../src/check_centreon_MS_multiple_services | 4 ++- .../src/check_centreon_snmp_TcpConn | 4 ++- centreon-plugins/src/check_centreon_snmp_cpu | 4 ++- .../src/check_centreon_snmp_loadaverage | 4 ++- .../src/check_centreon_snmp_memory | 4 ++- .../src/check_centreon_snmp_multiple_process | 12 +++++---- .../src/check_centreon_snmp_packetErrors | 4 ++- .../src/check_centreon_snmp_process | 4 ++- .../src/check_centreon_snmp_process_detailed | 22 +++------------ .../src/check_centreon_snmp_remote_storage | 6 +++-- .../src/check_centreon_snmp_string | 19 ++++++------- .../src/check_centreon_snmp_traffic | 4 ++- .../src/check_centreon_snmp_uptime | 4 ++- .../src/check_centreon_snmp_value | 4 ++- .../src/check_centreon_snmp_value_table.pl | 4 ++- centreon-plugins/src/check_snmp_cpfw.pl | 12 ++++----- centreon-plugins/src/check_snmp_load.pl | 25 ++--------------- centreon-plugins/src/check_snmp_mem.pl | 27 +++---------------- centreon-plugins/src/check_snmp_process.pl | 27 +++---------------- .../src/check_snmp_script_result.pl | 4 ++- centreon-plugins/src/check_snmp_storage.pl | 21 ++------------- centreon-plugins/src/check_snmp_win.pl | 21 ++------------- 23 files changed, 84 insertions(+), 164 deletions(-) diff --git a/centreon-plugins/src/Centreon/SNMP/Utils.pm b/centreon-plugins/src/Centreon/SNMP/Utils.pm index 628938218..9b1366638 100644 --- a/centreon-plugins/src/Centreon/SNMP/Utils.pm +++ b/centreon-plugins/src/Centreon/SNMP/Utils.pm @@ -66,7 +66,7 @@ sub check_snmp_options { my ($exit_status, $OPTION) = @_; my %session_params; - if (!defined($OPTION->{'host'})) { + if (!defined($OPTION->{host})) { print "Missing parameter -H (--host).\n"; exit $exit_status; } @@ -78,7 +78,7 @@ sub check_snmp_options { } if ($OPTION->{'snmp-version'} eq "3") { - %session_params = (-hostname => $OPTION->{'host'}, -version => $OPTION->{'snmp-version'}, -port => $OPTION->{'snmp-port'}); + %session_params = (-hostname => $OPTION->{host}, -version => $OPTION->{'snmp-version'}, -port => $OPTION->{'snmp-port'}); if (defined($OPTION->{'snmp-auth-password'}) && defined($OPTION->{'snmp-auth-key'})) { print "Only option -k (--authkey) or -p (--password) is needed for snmp v3\n"; @@ -141,6 +141,10 @@ sub check_snmp_options { } require bigint; } + + if (defined($OPTION->{snmptimeout}) && $OPTION->{snmptimeout} =~ /^[0-9]+$/) { + $session_params{-timeout} = $OPTION->{snmptimeout}; + } return (\%session_params); } diff --git a/centreon-plugins/src/check_centreon_MS_multiple_services b/centreon-plugins/src/check_centreon_MS_multiple_services index e38b6fc20..1d3f9a361 100644 --- a/centreon-plugins/src/check_centreon_MS_multiple_services +++ b/centreon-plugins/src/check_centreon_MS_multiple_services @@ -61,7 +61,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -80,6 +80,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, "V" => \$opt_V, "version" => \$opt_V, @@ -205,6 +206,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -n (--number) Return the number of current running processes. \n"; print " -p (--process) Set the process name ex: by default smbd\n"; print " -V (--version) Plugin version\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_TcpConn b/centreon-plugins/src/check_centreon_snmp_TcpConn index 7a7b96a83..29be70a7b 100644 --- a/centreon-plugins/src/check_centreon_snmp_TcpConn +++ b/centreon-plugins/src/check_centreon_snmp_TcpConn @@ -58,7 +58,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -77,6 +77,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, @@ -150,6 +151,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -p (--port) port you want to check - (required)\n"; print " -V (--version) Plugin version\n"; print " -h (--help) usage help\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_cpu b/centreon-plugins/src/check_centreon_snmp_cpu index da38199dc..77e15bd87 100644 --- a/centreon-plugins/src/check_centreon_snmp_cpu +++ b/centreon-plugins/src/check_centreon_snmp_cpu @@ -62,7 +62,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -81,6 +81,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, "V" => \$opt_V, "version" => \$opt_V, @@ -171,6 +172,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -c (--critical) Three critical tresholds (defaults : 95)\n"; print " -w (--warning) Three warning tresholds (defaults : 90)\n"; print " -l Display only cpu average\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_loadaverage b/centreon-plugins/src/check_centreon_snmp_loadaverage index 4615a45d3..1e9a28272 100644 --- a/centreon-plugins/src/check_centreon_snmp_loadaverage +++ b/centreon-plugins/src/check_centreon_snmp_loadaverage @@ -60,7 +60,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef ); @@ -79,6 +79,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, "V" => \$opt_V, "version" => \$opt_V, @@ -165,6 +166,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -c (--critical) Three critical tresholds (defaults : 2,4,6)\n"; print " -w (--warning) Three warning tresholds (defaults : 1,3,5)\n"; print " -V (--version) Plugin version\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_memory b/centreon-plugins/src/check_centreon_snmp_memory index bd2cd4427..5061345b6 100644 --- a/centreon-plugins/src/check_centreon_snmp_memory +++ b/centreon-plugins/src/check_centreon_snmp_memory @@ -66,7 +66,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, "disable-swap" => undef ); @@ -86,6 +86,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "S" => \$OPTION{'disable-swap'}, "h" => \$opt_h, "help" => \$opt_h, @@ -260,6 +261,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\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"; diff --git a/centreon-plugins/src/check_centreon_snmp_multiple_process b/centreon-plugins/src/check_centreon_snmp_multiple_process index 63c5ac5cb..61ea2b33c 100644 --- a/centreon-plugins/src/check_centreon_snmp_multiple_process +++ b/centreon-plugins/src/check_centreon_snmp_multiple_process @@ -63,7 +63,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -82,12 +82,13 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, - "h" => \$opt_h, "help" => \$opt_h, - "V" => \$opt_V, "version" => \$opt_V, - "p=s" => \$opt_p, "process=s" => \$opt_p, - "d" => \$opt_d, "debug" => \$opt_d); + "h" => \$opt_h, "help" => \$opt_h, + "V" => \$opt_V, "version" => \$opt_V, + "p=s" => \$opt_p, "process=s" => \$opt_p, + "d" => \$opt_d, "debug" => \$opt_d); if ($opt_V) { print_revision($PROGNAME,'$Revision: 1.2 $'); @@ -213,6 +214,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -p (--process) Set the process name ex: by default smbd\n"; print " -V (--version) Plugin version\n"; print " -h (--help) usage help\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_packetErrors b/centreon-plugins/src/check_centreon_snmp_packetErrors index f4cd2a750..f4fcb3762 100644 --- a/centreon-plugins/src/check_centreon_snmp_packetErrors +++ b/centreon-plugins/src/check_centreon_snmp_packetErrors @@ -64,7 +64,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -83,6 +83,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, @@ -245,6 +246,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -w (--warn) Signal strength at which a warning message will be generated\n"; print " (default 80)\n"; print " -c (--crit) Signal strength at which a critical message will be generated\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_process b/centreon-plugins/src/check_centreon_snmp_process index 6db8b0711..43163b66e 100644 --- a/centreon-plugins/src/check_centreon_snmp_process +++ b/centreon-plugins/src/check_centreon_snmp_process @@ -65,7 +65,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef ); @@ -84,6 +84,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, @@ -191,6 +192,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -n (--number) Return the number of current running processes. \n"; print " -w (--warning) Number of process that will cause a warning (only required with -n option)\n"; print " -c (--critical) Number of process that will cause an error (only required with -n option)\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_process_detailed b/centreon-plugins/src/check_centreon_snmp_process_detailed index c52538f19..9824778c2 100644 --- a/centreon-plugins/src/check_centreon_snmp_process_detailed +++ b/centreon-plugins/src/check_centreon_snmp_process_detailed @@ -32,7 +32,7 @@ use Getopt::Long; # Nagios specific use lib "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); +use utils qw(%ERRORS); # centreon specific require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm"; @@ -41,7 +41,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -70,7 +70,6 @@ my $o_version= undef; # print version my $o_noreg= undef; # Do not use Regexp for name my $o_path= undef; # check path instead of name my $o_inverse= undef; # checks max instead of min number of process -my $o_timeout= 5; # Default 5s Timeout # Memory & CPU my $o_mem= undef; # checks memory (max) my @o_memL= undef; # warn and crit level for mem @@ -98,12 +97,6 @@ sub isnotnum { # Return true if arg is not a number return 1; } -# Get the alarm signal (just in case snmp timout screws up) -$SIG{'ALRM'} = sub { - print ("ERROR: Alarm signal (Nagios time-out)\n"); - exit $ERRORS{"UNKNOWN"}; -}; - sub read_file { # Input : File, items_number # Returns : array of value : [line][item] @@ -233,12 +226,12 @@ sub check_options { "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, "64-bits" => \$OPTION{'64-bits'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, 'c:s' => \$o_crit, 'critical:s' => \$o_crit, 'w:s' => \$o_warn, 'warn:s' => \$o_warn, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, 'n:s' => \$o_descr, 'name:s' => \$o_descr, 'r' => \$o_noreg, 'noregexp' => \$o_noreg, 'f' => \$o_path, 'fullpath' => \$o_path, @@ -304,15 +297,6 @@ check_options(); $start=time; -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - #verb("Alarm at $TIMEOUT"); - alarm($TIMEOUT); -} else { - #verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); # Look for process in name or path name table diff --git a/centreon-plugins/src/check_centreon_snmp_remote_storage b/centreon-plugins/src/check_centreon_snmp_remote_storage index 6972a6d12..e3627497b 100644 --- a/centreon-plugins/src/check_centreon_snmp_remote_storage +++ b/centreon-plugins/src/check_centreon_snmp_remote_storage @@ -65,7 +65,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -84,6 +84,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, @@ -421,6 +422,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -d (--disk) Set the disk (number expected) ex: 1, 2,... (default: 2 )\n"; print " -n (--name) Allows to use disk name with option -d instead of disk oid index\n"; print " (ex: -d \"C:\" -n, -d \"E:\" -n, -d \"Swap Memory\" -n, -d \"Real Memory\" -n\n"; @@ -439,7 +441,7 @@ sub print_usage () { print " -V (--version) Plugin version\n"; print " -L add Windows drive label to output\n"; print " -M Shows the size in output in MB instead of GB\n"; - print " -t To use for AIX or AS/400 (ex. 'AIX' or 'AS/400'\n"; + print " -t To use for AIX or AS/400 (ex. 'AIX' or 'AS/400')\n"; print " -a (--cache) Updates cache file every n hours instead of doing snmpwalk for every check (default: 3)\n"; print " -h (--help) usage help\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_string b/centreon-plugins/src/check_centreon_snmp_string index 9027cd4dc..175f054be 100644 --- a/centreon-plugins/src/check_centreon_snmp_string +++ b/centreon-plugins/src/check_centreon_snmp_string @@ -50,7 +50,7 @@ my %OPTION = ("host" => undef, "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, 'help' => undef, 'output' => 'The value is %f'); @@ -75,6 +75,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$OPTION{'help'}, "help" => \$OPTION{'help'}, "V" => \$OPTION{'pluginversion'}, "version" => \$OPTION{'pluginversion'}, @@ -221,14 +222,14 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; - - print " -o (--oid) \t OID to check\n"; - print " -W (--warning_table) \t Personal warning threshold : -W warningstate... \n"; - print " -T (--critical_table) \t Personal critical threshold : -T criticalstate1,criticalstate2... \n"; - print " -O (--ok_table) \t Personal ok threshold : -O okstate1,okstate2... \n"; - print " -f (--output) \t Output format (ex : -f \"My metric's percentage value = %f %%\" \n"; - print " -V (--version) \t Plugin version\n"; - print " -h (--help) \t usage help\n"; + print " --snmp-timeout SNMP Timeout\n"; + print " -o (--oid) OID to check\n"; + print " -W (--warning_table) Personal warning threshold : -W warningstate... \n"; + print " -T (--critical_table) Personal critical threshold : -T criticalstate1,criticalstate2... \n"; + print " -O (--ok_table) Personal ok threshold : -O okstate1,okstate2... \n"; + print " -f (--output) Output format (ex : -f \"My metric's percentage value = %f %%\" \n"; + print " -V (--version) Plugin version\n"; + print " -h (--help) usage help\n"; } sub print_help () { diff --git a/centreon-plugins/src/check_centreon_snmp_traffic b/centreon-plugins/src/check_centreon_snmp_traffic index 27820f105..9a014d099 100644 --- a/centreon-plugins/src/check_centreon_snmp_traffic +++ b/centreon-plugins/src/check_centreon_snmp_traffic @@ -66,7 +66,7 @@ my %OPTION = ( "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", "maxrepetitions" => undef, - "64-bits" => undef, + "64-bits" => undef, "snmptimeout" => undef, "disable-warn-state" => undef ); @@ -89,6 +89,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "disable-warn-state" => \$OPTION{'disable-warn-state'}, @@ -555,6 +556,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -s (--show) Describes all interfaces number (debug mode)\n"; print " -i (--interface) Set the interface number (2 by default)\n"; print " -n (--name) Allows to use interface name with option -i instead of interface oid index\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_uptime b/centreon-plugins/src/check_centreon_snmp_uptime index 86a6ba59f..aa5153b07 100644 --- a/centreon-plugins/src/check_centreon_snmp_uptime +++ b/centreon-plugins/src/check_centreon_snmp_uptime @@ -58,7 +58,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); @@ -77,6 +77,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$opt_h, "help" => \$opt_h, "V" => \$opt_V, "version" => \$opt_V, @@ -165,6 +166,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -d (--day) Uptime in day\n"; print " -V (--version) Plugin version\n"; print " -h (--help) usage help\n"; diff --git a/centreon-plugins/src/check_centreon_snmp_value b/centreon-plugins/src/check_centreon_snmp_value index f1ab9c154..97cb78ed7 100644 --- a/centreon-plugins/src/check_centreon_snmp_value +++ b/centreon-plugins/src/check_centreon_snmp_value @@ -51,7 +51,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, 'help' => undef, 'warning' => '5', 'critical' => '10', @@ -79,6 +79,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$OPTION{'help'}, "help" => \$OPTION{'help'}, @@ -388,6 +389,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -t (--type) \t Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; print " -o (--oid) \t OID to check\n"; print " -w (--warning) \t Warning level \n"; diff --git a/centreon-plugins/src/check_centreon_snmp_value_table.pl b/centreon-plugins/src/check_centreon_snmp_value_table.pl index 229aca08b..707157704 100644 --- a/centreon-plugins/src/check_centreon_snmp_value_table.pl +++ b/centreon-plugins/src/check_centreon_snmp_value_table.pl @@ -52,7 +52,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, 'help' => undef, 'warning' => '0', 'critical' => '0', 'display' => 0, 'min' => 0, 'max' => 0, @@ -79,6 +79,7 @@ GetOptions "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, "h" => \$OPTION{'help'}, "help" => \$OPTION{'help'}, "V" => \$OPTION{'pluginversion'}, "version" => \$OPTION{'pluginversion'}, @@ -496,6 +497,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -t (--type) \t Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; print " -o (--oid) \t OID to check\n"; print " -w (--warning) \t Warning level \n"; diff --git a/centreon-plugins/src/check_snmp_cpfw.pl b/centreon-plugins/src/check_snmp_cpfw.pl index da68274ec..7a305ba20 100644 --- a/centreon-plugins/src/check_snmp_cpfw.pl +++ b/centreon-plugins/src/check_snmp_cpfw.pl @@ -19,15 +19,15 @@ use Getopt::Long; require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm"; use lib "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 15; +use utils qw(%ERRORS); + #my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); my %OPTION = ( "host" => undef, "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -145,7 +145,7 @@ sub help { -P, --port=PORT SNMP port (Default 161) -t, --timeout=INTEGER - timeout for SNMP (Default: Nagios default) + timeout for SNMP (Default: 5s) -V, --version prints version number -g (--rrdgraph) Create a rrd base if necessary and add datas into this one @@ -172,10 +172,10 @@ sub check_options { "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, - 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT, 'V' => \$o_version, 'version' => \$o_version, 's' => \$o_svn, 'svn' => \$o_svn, 'w' => \$o_fw, 'fw' => \$o_fw, @@ -219,8 +219,6 @@ sub check_options { check_options(); -# Check gobal timeout if snmp screws up -alarm($TIMEOUT+15); my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); ########### Global checks ################# diff --git a/centreon-plugins/src/check_snmp_load.pl b/centreon-plugins/src/check_snmp_load.pl index 9544b9a42..571888477 100644 --- a/centreon-plugins/src/check_snmp_load.pl +++ b/centreon-plugins/src/check_snmp_load.pl @@ -16,8 +16,6 @@ use Getopt::Long; require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm"; # Nagios specific - -my $TIMEOUT = 15; my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); # SNMP Datas @@ -26,7 +24,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -110,7 +108,6 @@ my $o_warn= undef; # warning level my @o_warnL= undef; # warning levels for Linux Load or Cisco CPU my $o_crit= undef; # critical level my @o_critL= undef; # critical level for Linux Load or Cisco CPU -my $o_timeout= undef; # Timeout (Default 5) my $o_perf= undef; # Output performance data # functions @@ -195,11 +192,11 @@ sub check_options { "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, 'V' => \$o_version, 'version' => \$o_version, 'c:s' => \$o_crit, 'critical:s' => \$o_crit, 'w:s' => \$o_warn, 'warn:s' => \$o_warn, @@ -213,10 +210,6 @@ sub check_options { foreach (@valid_types) { if ($_ eq $o_check_type) {$T_option_valid=1} }; if ( $T_option_valid == 0 ) {print "Invalid check type (-T)!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - # Basic checks - if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) - { print "Timeout must be >1 and <60 !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - if (!defined($o_timeout)) {$o_timeout=5;} if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}}; if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}}; # Check warnings and critical @@ -253,20 +246,6 @@ sub check_options { check_options(); -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT + 5"); - alarm($TIMEOUT+5); -} else { - verb("no global timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - -$SIG{'ALRM'} = sub { - print "No answer from host\n"; - exit $ERRORS{"UNKNOWN"}; -}; - # Connect to host my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); diff --git a/centreon-plugins/src/check_snmp_mem.pl b/centreon-plugins/src/check_snmp_mem.pl index 0b9cc24db..68c5f6952 100644 --- a/centreon-plugins/src/check_snmp_mem.pl +++ b/centreon-plugins/src/check_snmp_mem.pl @@ -19,8 +19,7 @@ require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm"; # Nagios specific use lib "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 15; +use utils qw(%ERRORS); #my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); # SNMP Datas @@ -29,7 +28,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -85,7 +84,6 @@ my $o_critR= undef; # critical level for Real memory my $o_critS= undef; # critical level for swap my $o_perf= undef; # Performance data option my $o_cache= undef; # Include cached memory as used memory -my $o_timeout= undef; # Timeout (Default 5) # functions @@ -151,12 +149,6 @@ EOT # For verbose output sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; } -# Get the alarm signal (just in case snmp timout screws up) -$SIG{'ALRM'} = sub { - print ("ERROR: Alarm signal (Nagios time-out)\n"); - exit $ERRORS{"UNKNOWN"}; -}; - sub check_options { Getopt::Long::Configure ("bundling"); GetOptions( @@ -172,10 +164,11 @@ sub check_options { "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, + 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, 'V' => \$o_version, 'version' => \$o_version, 'I' => \$o_cisco, 'cisco' => \$o_cisco, 'N' => \$o_netsnmp, 'netsnmp' => \$o_netsnmp, @@ -189,9 +182,6 @@ sub check_options { if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}}; # check snmp information ($session_params) = Centreon::SNMP::Utils::check_snmp_options($ERRORS{'UNKNOWN'}, \%OPTION); - if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) - { print "Timeout must be >1 and <60 !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - if (!defined($o_timeout)) {$o_timeout=5;} #Check Warning and crit are present if ( ! defined($o_warn) || ! defined($o_crit)) { print "Put warning and critical values!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} @@ -229,15 +219,6 @@ sub check_options { check_options(); -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT"); - alarm($TIMEOUT); -} else { - verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - # Connect to host my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); diff --git a/centreon-plugins/src/check_snmp_process.pl b/centreon-plugins/src/check_snmp_process.pl index b40e85cfe..22fd579be 100644 --- a/centreon-plugins/src/check_snmp_process.pl +++ b/centreon-plugins/src/check_snmp_process.pl @@ -23,8 +23,6 @@ my $file_history=200; # number of data to keep in files. my $delta_of_time_to_make_average=300; # 5minutes by default # Nagios specific - -my $TIMEOUT = 15; my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); my %OPTION = ( @@ -32,7 +30,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -62,7 +60,6 @@ my $o_inverse= undef; # checks max instead of min number of process my $o_get_all= undef; # get all tables at once my $o_param= undef; # Add process parameters for selection my $o_perf= undef; # Add performance output -my $o_timeout= 5; # Default 5s Timeout # Memory & CPU my $o_mem= undef; # checks memory (max) my @o_memL= undef; # warn and crit level for mem @@ -85,12 +82,6 @@ sub isnotnum { # Return true if arg is not a number return 1; } -# Get the alarm signal (just in case snmp timout screws up) -$SIG{'ALRM'} = sub { - print ("ERROR: Alarm signal (Nagios time-out)\n"); - exit $ERRORS{"UNKNOWN"}; -}; - sub read_file { # Input : File, items_number # Returns : array of value : [line][item] @@ -213,7 +204,7 @@ sub verb { my $t=shift; print $t,"\n" if defined($o_verb) ; } sub check_options { Getopt::Long::Configure ("bundling"); GetOptions( - "H|hostname|host=s" => \$OPTION{'host'}, + "H|hostname|host=s" => \$OPTION{'host'}, "C|community=s" => \$OPTION{'snmp-community'}, "snmp|snmp-version=s" => \$OPTION{'snmp-version'}, "p|port|P|snmpport|snmp-port=i" => \$OPTION{'snmp-port'}, @@ -225,13 +216,13 @@ sub check_options { "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, 'c:s' => \$o_crit, 'critical:s' => \$o_crit, 'w:s' => \$o_warn, 'warn:s' => \$o_warn, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, 'n:s' => \$o_descr, 'name:s' => \$o_descr, 'r' => \$o_noreg, 'noregexp' => \$o_noreg, 'f' => \$o_path, 'fullpath' => \$o_path, @@ -248,9 +239,6 @@ sub check_options { if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}}; # check snmp information ($session_params) = Centreon::SNMP::Utils::check_snmp_options($ERRORS{'UNKNOWN'}, \%OPTION); - if (defined($o_timeout) && (isnotnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) - { print "Timeout must be >1 and <60 !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - if (!defined($o_timeout)) {$o_timeout=5;} # Check compulsory attributes if ( ! defined($o_descr) ) { print_usage(); exit $ERRORS{"UNKNOWN"}}; @o_warnL=split(/,/,$o_warn); @@ -298,15 +286,6 @@ sub check_options { check_options(); -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT"); - alarm($TIMEOUT); -} else { - verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); # Look for process in name or path name table diff --git a/centreon-plugins/src/check_snmp_script_result.pl b/centreon-plugins/src/check_snmp_script_result.pl index 91fbf7669..bfdcfb970 100644 --- a/centreon-plugins/src/check_snmp_script_result.pl +++ b/centreon-plugins/src/check_snmp_script_result.pl @@ -40,7 +40,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, "command-exit" => undef, "no-regexp" => undef, @@ -59,6 +59,7 @@ GetOptions "privpassword=s" => \$OPTION{'snmp-priv-password'}, "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, + "snmp-timeout=i" => \$OPTION{'snmptimeout'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, "64-bits" => \$OPTION{'64-bits'}, "command-exit" => \$OPTION{'command-exit'}, @@ -142,6 +143,7 @@ sub print_usage () { print " --64-bits Use 64 bits OID\n"; print " --maxrepetitions To use when you have the error: 'Message size exceeded buffer maxMsgSize'\n"; print " Work only with SNMP v2c and v3 (Example: --maxrepetitions=1)\n"; + print " --snmp-timeout SNMP Timeout\n"; print " -n (--name) SNMP Command name to call\n"; print " Example in snmpd.conf: exec echotest /bin/echo hello world\n"; print " So we specify: -n 'echotest'\n"; diff --git a/centreon-plugins/src/check_snmp_storage.pl b/centreon-plugins/src/check_snmp_storage.pl index 58f1ed408..7250fbde7 100644 --- a/centreon-plugins/src/check_snmp_storage.pl +++ b/centreon-plugins/src/check_snmp_storage.pl @@ -19,7 +19,6 @@ require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm"; use lib "@NAGIOS_PLUGINS@"; use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 15; #my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); my %OPTION = ( @@ -27,7 +26,7 @@ my %OPTION = ( "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -82,7 +81,6 @@ my $o_noreg= undef; # Do not use Regexp for name my $o_sum= undef; # add all storage before testing my $o_index= undef; # Parse index instead of description my $o_negate= undef; # Negate the regexp if set -my $o_timeout= 5; # Default 5s Timeout my $o_perf= undef; # Output performance data my $o_short= undef; # Short output parameters my @o_shortL= undef; # output type,where,cut @@ -107,12 +105,6 @@ sub is_pattern_valid { # Test for things like "" or "+5-i" return eval { "" =~ /$pat/; 1 } || 0; } -# Get the alarm signal (just in case snmp timout screws up) -$SIG{'ALRM'} = sub { - print ("ERROR: General time-out (Alarm signal)\n"); - exit $ERRORS{"UNKNOWN"}; -}; - sub isnnum { # Return true if arg is not a number my $num = shift; if ( $num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;} @@ -229,12 +221,12 @@ sub check_options { "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, 'c:s' => \$o_crit, 'critical:s' => \$o_crit, 'w:s' => \$o_warn, 'warn:s' => \$o_warn, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, 'm:s' => \$o_descr, 'name:s' => \$o_descr, 'T:s' => \$o_type, 'type:s' => \$o_type, 'r' => \$o_noreg, 'noregexp' => \$o_noreg, @@ -302,15 +294,6 @@ sub check_options { check_options(); -# Check gobal timeout -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT"); - alarm($TIMEOUT); -} else { - verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - # Connect to host my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); my $resultat=undef; diff --git a/centreon-plugins/src/check_snmp_win.pl b/centreon-plugins/src/check_snmp_win.pl index 88baa69d4..641a6e636 100644 --- a/centreon-plugins/src/check_snmp_win.pl +++ b/centreon-plugins/src/check_snmp_win.pl @@ -18,14 +18,13 @@ require "@NAGIOS_PLUGINS@/Centreon/SNMP/Utils.pm"; use lib "@NAGIOS_PLUGINS@"; use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 5; #my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); my %OPTION = ( "host" => undef, "snmp-community" => "public", "snmp-version" => 1, "snmp-port" => 161, "snmp-auth-key" => undef, "snmp-auth-user" => undef, "snmp-auth-password" => undef, "snmp-auth-protocol" => "MD5", "snmp-priv-key" => undef, "snmp-priv-password" => undef, "snmp-priv-protocol" => "DES", - "maxrepetitions" => undef, + "maxrepetitions" => undef, "snmptimeout" => undef, "64-bits" => undef, ); my $session_params; @@ -65,7 +64,6 @@ my $o_help= undef; # wan't some help ? my $o_verb= undef; # verbose mode my $o_version= undef; # print version my $o_noreg= undef; # Do not use Regexp for name -my $o_timeout= 5; # Default 5s Timeout # functions @@ -87,12 +85,6 @@ sub is_pattern_valid { # Test for things like "" or "+5-i" return eval { "" =~ /$pat/; 1 } || 0; } -# Get the alarm signal (just in case snmp timout screws up) -$SIG{'ALRM'} = sub { - print ("ERROR: Alarm signal (Nagios time-out)\n"); - exit $ERRORS{"UNKNOWN"}; -}; - sub help { print "\nSNMP Windows Monitor for Nagios version ",$Version,"\n"; print "GPL licence, (c)2004-2005 Patrick Proy\n\n"; @@ -171,10 +163,10 @@ sub check_options { "privkey=s" => \$OPTION{'snmp-priv-key'}, "privprotocol=s" => \$OPTION{'snmp-priv-protocol'}, "maxrepetitions=s" => \$OPTION{'maxrepetitions'}, + "t|timeout|snmp-timeout=i" => \$OPTION{'snmptimeout'}, "64-bits" => \$OPTION{'64-bits'}, 'v' => \$o_verb, 'verbose' => \$o_verb, 'h' => \$o_help, 'help' => \$o_help, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, 'n:s' => \$o_descr, 'name:s' => \$o_descr, 'r' => \$o_noreg, 'noregexp' => \$o_noreg, 'T:s' => \$o_type, 'type:s' => \$o_type, @@ -207,15 +199,6 @@ sub check_options { check_options(); -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT"); - alarm($TIMEOUT); -} else { - verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - # Connect to host my $session = Centreon::SNMP::Utils::connection($ERRORS{'UNKNOWN'}, $session_params); $session->translate(Net::SNMP->TRANSLATE_OCTET_STRING);