Просмотр исходного кода

Option to check for admin down (#1012191) from Raúl Pedroche.

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1010 f882894a-f735-0410-b71e-b25c423dba1c
Matthew Kent 21 лет назад
Родитель
Сommit
b5b298c725
1 измененных файлов с 15 добавлено и 5 удалено
  1. 15 5
      plugins-scripts/check_ifoperstatus.pl

+ 15 - 5
plugins-scripts/check_ifoperstatus.pl

@@ -86,6 +86,7 @@ my $ifdescr;
 my $key;
 my $key;
 my $lastc;
 my $lastc;
 my $dormantWarn;
 my $dormantWarn;
+my $adminWarn;
 my $name;
 my $name;
 
 
 ### Validate Arguments
 ### Validate Arguments
@@ -168,9 +169,16 @@ push(@snmpoids,$snmpIfAlias) if (defined $ifXTable) ;
    ## if AdminStatus is down - some one made a consious effort to change config
    ## if AdminStatus is down - some one made a consious effort to change config
    ##
    ##
    if ( not ($response->{$snmpIfAdminStatus} == 1) ) {
    if ( not ($response->{$snmpIfAdminStatus} == 1) ) {
-      $state = 'WARNING';
-      $answer = "Interface $name (index $snmpkey) is administratively down.";
-
+     $answer = "Interface $name (index $snmpkey) is administratively down.";
+     if ( not defined $adminWarn or $adminWarn eq "w" ) {
+        $state = 'WARNING';
+     } elsif ( $adminWarn eq "i" ) {
+        $state = 'OK';
+     } elsif ( $adminWarn eq "c" ) {
+        $state = 'CRITICAL';
+     } else { # If wrong value for -a, say warning
+        $state = 'WARNING';
+     }
    } 
    } 
    ## Check operational status
    ## Check operational status
    elsif ( $response->{$snmpIfOperStatus} == 2 ) {
    elsif ( $response->{$snmpIfOperStatus} == 2 ) {
@@ -179,7 +187,7 @@ push(@snmpoids,$snmpIfAlias) if (defined $ifXTable) ;
    } elsif ( $response->{$snmpIfOperStatus} == 5 ) {
    } elsif ( $response->{$snmpIfOperStatus} == 5 ) {
       if (defined $dormantWarn ) {
       if (defined $dormantWarn ) {
 				if ($dormantWarn eq "w") {
 				if ($dormantWarn eq "w") {
-		  	  $state = 'WARNNG';
+		  	  $state = 'WARNING';
 				  $answer = "Interface $name (index $snmpkey) is dormant.";
 				  $answer = "Interface $name (index $snmpkey) is dormant.";
 	  	  }elsif($dormantWarn eq "c") {
 	  	  }elsif($dormantWarn eq "c") {
 	  	  	$state = 'CRITICAL';
 	  	  	$state = 'CRITICAL';
@@ -286,6 +294,7 @@ sub print_help() {
 	printf "   -n (--name)       the value should match the returned ifName\n";
 	printf "   -n (--name)       the value should match the returned ifName\n";
 	printf "                     (Implies the use of -I)\n";
 	printf "                     (Implies the use of -I)\n";
 	printf "   -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
 	printf "   -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n";
+	printf "   -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n";
 	printf "   -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
 	printf "   -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n";
 	printf "   -t (--timeout)    seconds before the plugin times out (default=$TIMEOUT)\n";
 	printf "   -t (--timeout)    seconds before the plugin times out (default=$TIMEOUT)\n";
 	printf "   -V (--version)    Plugin version\n";
 	printf "   -V (--version)    Plugin version\n";
@@ -316,9 +325,10 @@ sub process_arguments() {
 			"l=s" => \$lastc,  "lastchange=s" => \$lastc,
 			"l=s" => \$lastc,  "lastchange=s" => \$lastc,
 			"p=i" => \$port,  "port=i" =>\$port,
 			"p=i" => \$port,  "port=i" =>\$port,
 			"H=s" => \$hostname, "hostname=s" => \$hostname,
 			"H=s" => \$hostname, "hostname=s" => \$hostname,
-			"I"	  => \$ifXTable, "ifmib" => \$ifXTable,
+			"I"   => \$ifXTable, "ifmib" => \$ifXTable,
 			"n=s" => \$ifName, "name=s" => \$ifName,
 			"n=s" => \$ifName, "name=s" => \$ifName,
 			"w=s" => \$dormantWarn, "warn=s" => \$dormantWarn,
 			"w=s" => \$dormantWarn, "warn=s" => \$dormantWarn,
+			"D=s" => \$adminWarn, "admin-down=s" => \$adminWarn,
 			"M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
 			"M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
 			"t=i" => \$timeout,    "timeout=i" => \$timeout,
 			"t=i" => \$timeout,    "timeout=i" => \$timeout,
 			);
 			);