Fix #4696
This commit is contained in:
parent
8ff55b4ba5
commit
f97c655ec7
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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 () {
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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 #################
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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 "<I\s*[^>" 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;
|
||||
|
|
|
@ -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 "<I\s*[^>" 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);
|
||||
|
|
Loading…
Reference in New Issue