diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-07-05 13:45:57 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-07-05 13:45:57 +0000 |
commit | 5f9761ed60091476d9e86bbb0e306776c0823fcb (patch) | |
tree | 960b917e19fc01a19eb205f49391256d2bf00e22 /plugins-scripts/check_mailq.pl | |
parent | 4240aba33f68bf8f9882023c952abf13b7a12f5b (diff) | |
download | monitoring-plugins-5f9761ed60091476d9e86bbb0e306776c0823fcb.tar.gz |
Fixed checking of return codes from external mailq programs
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1443 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins-scripts/check_mailq.pl')
-rwxr-xr-x | plugins-scripts/check_mailq.pl | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index f1aec0f4..c676e41a 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl @@ -186,12 +186,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 +316,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 +397,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 +484,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'}; |