Code

Detect arguments passed via --with-ping[6]-command (#2908236)
[nagiosplug.git] / plugins-scripts / check_mailq.pl
index f1aec0f400152b8e828403231376ac91a88ffdf9..31eb46a4d5aa93da85f39e07e25b93f8930e6c39 100755 (executable)
@@ -22,7 +22,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
-# $Id$
 #
 ############################################################################
 
@@ -186,12 +185,10 @@ if ($mailq eq "sendmail") {
        ## 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 +315,10 @@ elsif ( $mailq eq "postfix" ) {
 
         # 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 +396,10 @@ elsif ( $mailq eq "qmail" ) {
 
        # 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 +483,11 @@ elsif ( $mailq eq "exim" ) {
            }
        }
        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'};
@@ -523,7 +521,7 @@ sub process_arguments(){
                 );
 
        if ($opt_V) {
-               print_revision($PROGNAME,'$Revision$ ');
+               print_revision($PROGNAME,'@NP_VERSION@');
                exit $ERRORS{'OK'};
        }
 
@@ -581,7 +579,7 @@ sub print_usage () {
 }
 
 sub print_help () {
-       print_revision($PROGNAME,'$Revision$');
+       print_revision($PROGNAME,'@NP_VERSION@');
        print "Copyright (c) 2002 Subhendu Ghosh/Carlos Canau/Benjamin Schmid\n";
        print "\n";
        print_usage();
@@ -589,7 +587,7 @@ sub print_help () {
        print "   Checks the number of messages in the mail queue (supports multiple sendmail queues, qmail)\n";
        print "   Feedback/patches to support non-sendmail mailqueue welcome\n\n";
        print "-w (--warning)   = Min. number of messages in queue to generate warning\n";
-       print "-c (--critical)  = Min. number of messages in queu to generate critical alert ( w < c )\n";
+       print "-c (--critical)  = Min. number of messages in queue to generate critical alert ( w < c )\n";
        print "-W (--Warning)   = Min. number of messages for same domain in queue to generate warning\n";
        print "-C (--Critical)  = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
        print "-t (--timeout)   = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";