index aaec2515c8379b8e1646600c17bd21f2fe999eb7..31eb46a4d5aa93da85f39e07e25b93f8930e6c39 100755 (executable)
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
+#
############################################################################
use POSIX;
# multi queue: one for each queue. overwrite on multi queue below
$msg_q = $1 ;
}
- } elsif (/^\s+Total\sRequests:\s(\d+)$/) {
+ } elsif (/^\s+Total\sRequests:\s(\d+)$/i) {
print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ;
#
# multi queue: last line
## 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
# 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
# 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
}
}
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'};
"M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default sendmail)
"w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number
"c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
- "W=i" => \$opt_W, "Warning=i" => \$opt_W, # warning if above this number
- "C=i" => \$opt_C, "Critical=i" => \$opt_C, # critical if above this number
"t=i" => \$opt_t, "timeout=i" => \$opt_t
);
if ($opt_V) {
- print_revision($PROGNAME,'$Revision$ ');
+ print_revision($PROGNAME,'@NP_VERSION@');
exit $ERRORS{'OK'};
}
}
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();
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";