Procházet zdrojové kódy

check_bro.sh: fix logic error in capture loss check

Because the value of threshold was not tested for
the script would return with code 2 if there was loss
but not greater than the threshold.

        if ( threshold > 0 ) {
            exit 2
        }
Jon Schipp před 12 roky
rodič
revize
0232e5c32b
1 změnil soubory, kde provedl 8 přidání a 8 odebrání
  1. 8 8
      check_bro.sh

+ 8 - 8
check_bro.sh

@@ -265,20 +265,20 @@ if [ $CAPTURE_LOSS_CHECK -eq 1 ]; then
                  }
                  }
 
 
                 END {
                 END {
-                        if ( loss >= 1 ) {
-				print "\n--------------------\n"loss,"instances of loss with",threshold,"exceeding the threshold ("crit"%).";
-                                exit 2
+			 if ( loss >= 1 ) {
+                                print "\n--------------------\n"loss,"instances of loss with",threshold,"exceeding the threshold ("crit"%).";
+                                if ( threshold > 0 ) {
+                                        exit 2
+                                }
+                                exit 0
                         }
                         }
                 else
                 else
                          print "\nNo loss detected"; }' $CAPTURE_LOG
                          print "\nNo loss detected"; }' $CAPTURE_LOG
 
 
-        if [ $? -eq 2 ]; then
+	if [ $? -eq 2 ]; then
                 exit $CRITICAL
                 exit $CRITICAL
-        elif [ $? -eq 0 ]; then
-                exit $OK
         else
         else
-                echo "Unknown status code: $?"
-                exit $UNKNOWN
+                exit $OK
         fi
         fi
 fi
 fi