[monitoring-plugins] check_mailq: adding nullmailer support
Git Repository
git at monitoring-plugins.org
Wed Jan 29 13:50:09 CET 2014
Module: monitoring-plugins
Branch: master
Commit: 2dc150da81169ec6d81858478b6203eb3aa164a9
Author: Jan Wagner <waja at cyconet.org>
Date: Tue Oct 1 12:43:39 2013 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=2dc150d
check_mailq: adding nullmailer support
Adding nullmailer support to check_mailq submitted by Luca Corti
Closes: #740
Closes: #1189
---
THANKS.in | 1 +
plugins-scripts/check_mailq.pl | 41 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/THANKS.in b/THANKS.in
index e9196a5..aef787c 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -304,3 +304,4 @@ Steve Weinreich
Geoff Oakham
Tim Laszlo
Stéphane Bortzmeyer
+Luca Corti
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 9de8f02..2a805b6 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -500,6 +500,43 @@ elsif ( $mailq eq "exim" ) {
}
} # end of ($mailq eq "exim")
+elsif ( $mailq eq "nullmailer" ) {
+ ## open mailq
+ if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
+ if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
+ print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
+ exit $ERRORS{'UNKNOWN'};
+ }
+ }elsif( defined $utils::PATH_TO_MAILQ){
+ unless (-x $utils::PATH_TO_MAILQ) {
+ print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n";
+ exit $ERRORS{'UNKNOWN'};
+ }
+ } else {
+ print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n";
+ exit $ERRORS{'UNKNOWN'};
+ }
+
+ while (<MAILQ>) {
+ #2006-06-22 16:00:00 282 bytes
+
+ if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) {
+ $msg_q++ ;
+ }
+ }
+ close(MAILQ) ;
+ if ($msg_q < $opt_w) {
+ $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+ $state = $ERRORS{'OK'};
+ }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) {
+ $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)";
+ $state = $ERRORS{'WARNING'};
+ }else {
+ $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)";
+ $state = $ERRORS{'CRITICAL'};
+ }
+} # end of ($mailq eq "nullmailer")
+
# Perfdata support
print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n";
exit $state;
@@ -559,7 +596,7 @@ sub process_arguments(){
}
if (defined $opt_M) {
- if ($opt_M =~ /^(sendmail|qmail|postfix|exim)$/) {
+ if ($opt_M =~ /^(sendmail|qmail|postfix|exim|nullmailer)$/) {
$mailq = $opt_M ;
}elsif( $opt_M eq ''){
$mailq = 'sendmail';
@@ -591,7 +628,7 @@ sub print_help () {
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";
- print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n";
+ print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = sendmail)\n";
print "-h (--help)\n";
print "-V (--version)\n";
print "-v (--verbose) = debugging output\n";
More information about the Commits
mailing list