[Nagiosplug-checkins] nagiosplug/plugins-scripts check_mailq.pl, 1.6, 1.7

Ton Voon tonvoon at users.sourceforge.net
Wed Jul 5 15:45:59 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins-scripts
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv31208

Modified Files:
	check_mailq.pl 
Log Message:
Fixed checking of return codes from external mailq programs


Index: check_mailq.pl
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins-scripts/check_mailq.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- check_mailq.pl	14 Apr 2005 04:13:13 -0000	1.6
+++ check_mailq.pl	5 Jul 2006 13:45:57 -0000	1.7
@@ -186,12 +186,10 @@
 	## close mailq
 
 	close (MAILQ); 
-	# declare an error if we also get a non-zero return code from mailq
-	# unless already set to critical
+
 	if ( $? ) {
-		$state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"}  ;
-		print "STDERR $?: $!\n" if $verbose;
-		$msg = "$state: (stderr)\n";
+		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
+		exit $ERRORS{CRITICAL};
 	}
 
 	## shut off the alarm
@@ -318,12 +316,10 @@
 
         # close qmail-qstat
         close MAILQ;
-        # declare an error if we also get a non-zero return code from mailq
-        # unless already set to critical
+
         if ( $? ) {
-                $state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"}  ;
-                print "STDERR $?: $!\n" if $verbose;
-                $msg = "$state: (stderr)\n";
+		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
+		exit $ERRORS{CRITICAL};
         }
 
         ## shut off the alarm
@@ -401,12 +397,10 @@
 
 	# close qmail-qstat
 	close MAILQ;
-	# declare an error if we also get a non-zero return code from mailq
-	# unless already set to critical
+
 	if ( $? ) {
-		$state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"}  ;
-		print "STDERR $?: $!\n" if $verbose;
-		$msg = "$state: (stderr)\n";
+		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
+		exit $ERRORS{CRITICAL};
 	}
 
 	## shut off the alarm
@@ -490,6 +484,11 @@
 	    }
 	}
 	close(MAILQ) ;
+
+	if ( $? ) {
+		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
+		exit $ERRORS{CRITICAL};
+	}
 	if ($msg_q < $opt_w) {
 		$msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
 		$state = $ERRORS{'OK'};





More information about the Commits mailing list