summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rw-r--r--plugins-scripts/check_ifoperstatus.pl21
-rwxr-xr-xplugins-scripts/check_ifstatus.pl11
2 files changed, 23 insertions, 9 deletions
diff --git a/plugins-scripts/check_ifoperstatus.pl b/plugins-scripts/check_ifoperstatus.pl
index 8a23ca5..a43e9f4 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
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 4f17711..7452394 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -56,6 +56,7 @@ my %ifOperStatus = ('1','up',
56 '6','notPresent', 56 '6','notPresent',
57 '7','lowerLayerDown'); # down due to the state of lower layer interface(s)); 57 '7','lowerLayerDown'); # down due to the state of lower layer interface(s));
58 58
59my $timeout ;
59my $state = "UNKNOWN"; 60my $state = "UNKNOWN";
60my $answer = ""; 61my $answer = "";
61my $snmpkey=0; 62my $snmpkey=0;
@@ -114,7 +115,7 @@ if ($status != 0)
114} 115}
115 116
116 117
117alarm($TIMEOUT); 118alarm($timeout);
118 119
119push(@snmpoids,$snmpIfOperStatus); 120push(@snmpoids,$snmpIfOperStatus);
120push(@snmpoids,$snmpIfAdminStatus); 121push(@snmpoids,$snmpIfAdminStatus);
@@ -251,6 +252,7 @@ sub print_help (){
251 printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; 252 printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n";
252 printf " privacy password and authEngineID\n"; 253 printf " privacy password and authEngineID\n";
253 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; 254 printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
255 printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n";
254 printf " -V (--version) Plugin version\n"; 256 printf " -V (--version) Plugin version\n";
255 printf " -h (--help) usage help \n\n"; 257 printf " -h (--help) usage help \n\n";
256 print_revision($PROGNAME, '$Revision$'); 258 print_revision($PROGNAME, '$Revision$');
@@ -274,7 +276,9 @@ sub process_arguments() {
274 "I" => \$ifXTable, "ifmib" => \$ifXTable, 276 "I" => \$ifXTable, "ifmib" => \$ifXTable,
275 "x:s" => \$opt_x, "exclude:s" => \$opt_x, 277 "x:s" => \$opt_x, "exclude:s" => \$opt_x,
276 "u=s" => \$opt_u, "unused_ports=s" => \$opt_u, 278 "u=s" => \$opt_u, "unused_ports=s" => \$opt_u,
277 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize); 279 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
280 "t=i" => \$timeout, "timeout=i" => \$timeout,
281 );
278 282
279 if ($status == 0){ 283 if ($status == 0){
280 print_help() ; 284 print_help() ;
@@ -290,6 +294,9 @@ sub process_arguments() {
290 exit $ERRORS{'OK'}; 294 exit $ERRORS{'OK'};
291 } 295 }
292 296
297 unless (defined $timeout) {
298 $timeout = $TIMEOUT;
299 }
293 300
294 if ($snmp_version =~ /3/ ) { 301 if ($snmp_version =~ /3/ ) {
295 # Must define a security level even though default is noAuthNoPriv 302 # Must define a security level even though default is noAuthNoPriv