summaryrefslogtreecommitdiffstats
path: root/plugins-scripts/check_ifoperstatus.pl
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts/check_ifoperstatus.pl')
-rw-r--r--plugins-scripts/check_ifoperstatus.pl21
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 8a23ca5e..a43e9f4d 100644
--- a/plugins-scripts/check_ifoperstatus.pl
+++ b/plugins-scripts/check_ifoperstatus.pl
@@ -47,6 +47,7 @@ sub print_help ();
47sub usage (); 47sub usage ();
48sub process_arguments (); 48sub process_arguments ();
49 49
50my $timeout;
50my $status; 51my $status;
51my %ifOperStatus = ('1','up', 52my %ifOperStatus = ('1','up',
52 '2','down', 53 '2','down',
@@ -87,6 +88,9 @@ my $lastc;
87my $dormantWarn; 88my $dormantWarn;
88my $name; 89my $name;
89 90
91### Validate Arguments
92
93$status = process_arguments();
90 94
91 95
92# Just in case of problems, let's not hang Nagios 96# Just in case of problems, let's not hang Nagios
@@ -94,12 +98,8 @@ $SIG{'ALRM'} = sub {
94 print ("ERROR: No snmp response from $hostname (alarm)\n"); 98 print ("ERROR: No snmp response from $hostname (alarm)\n");
95 exit $ERRORS{"UNKNOWN"}; 99 exit $ERRORS{"UNKNOWN"};
96}; 100};
97alarm($TIMEOUT);
98
99
100### Validate Arguments
101 101
102$status = process_arguments(); 102alarm($timeout);
103 103
104 104
105## map ifdescr to ifindex - should look at being able to cache this value 105## map ifdescr to ifindex - should look at being able to cache this value
@@ -287,6 +287,7 @@ sub print_help() {
287 printf " (Implies the use of -I)\n"; 287 printf " (Implies the use of -I)\n";
288 printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n"; 288 printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
289 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; 289 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
290 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
290 printf " -V (--version) Plugin version\n"; 291 printf " -V (--version) Plugin version\n";
291 printf " -h (--help) usage help \n\n"; 292 printf " -h (--help) usage help \n\n";
292 printf " -k or -d must be specified\n\n"; 293 printf " -k or -d must be specified\n\n";
@@ -313,12 +314,14 @@ sub process_arguments() {
313 "k=i" => \$snmpkey, "key=i",\$snmpkey, 314 "k=i" => \$snmpkey, "key=i",\$snmpkey,
314 "d=s" => \$ifdescr, "descr=s" => \$ifdescr, 315 "d=s" => \$ifdescr, "descr=s" => \$ifdescr,
315 "l=s" => \$lastc, "lastchange=s" => \$lastc, 316 "l=s" => \$lastc, "lastchange=s" => \$lastc,
316 "p=i" = >\$port, "port=i" =>\$port, 317 "p=i" => \$port, "port=i" =>\$port,
317 "H=s" => \$hostname, "hostname=s" => \$hostname, 318 "H=s" => \$hostname, "hostname=s" => \$hostname,
318 "I" => \$ifXTable, "ifmib" => \$ifXTable, 319 "I" => \$ifXTable, "ifmib" => \$ifXTable,
319 "n=s" => \$ifName, "name=s" => \$ifName, 320 "n=s" => \$ifName, "name=s" => \$ifName,
320 "w=s" => \$dormantWarn, "warn=s" => \$dormantWarn, 321 "w=s" => \$dormantWarn, "warn=s" => \$dormantWarn,
321 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize); 322 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
323 "t=i" => \$timeout, "timeout=i" => \$timeout,
324 );
322 325
323 326
324 327
@@ -361,6 +364,10 @@ sub process_arguments() {
361 } 364 }
362 } 365 }
363 366
367 unless (defined $timeout) {
368 $timeout = $TIMEOUT;
369 }
370
364 if ($snmp_version =~ /3/ ) { 371 if ($snmp_version =~ /3/ ) {
365 # Must define a security level even though default is noAuthNoPriv 372 # Must define a security level even though default is noAuthNoPriv
366 # v3 requires a security username 373 # v3 requires a security username