From 9328b585951a9c91cae140e93a1929591f4b4cf6 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Mon, 15 Sep 2003 15:28:35 +0000 Subject: Added Exim support (768445 - Eric Bollengier) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@726 f882894a-f735-0410-b71e-b25c423dba1c --- plugins-scripts/check_mailq.pl | 43 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl index 0505207b..aaec2515 100755 --- a/plugins-scripts/check_mailq.pl +++ b/plugins-scripts/check_mailq.pl @@ -462,11 +462,46 @@ elsif ( $mailq eq "qmail" ) { } # end of ($mailq eq "qmail") +elsif ( $mailq eq "exim" ) { + ## 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 () { + #22m 1.7K 19aEEr-0007hx-Dy <> *** frozen *** + #root@exlixams.glups.fr + if (/\s[\w\d]{6}-[\w\d]{6}-[\w\d]{2}\s/) { # message id 19aEEr-0007hx-Dy + $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 "exim") # Perfdata support -print "$msg |mailq=$msg_q\n"; +print "$msg|unsent=$msg_q;$opt_w;$opt_c;0\n"; exit $state; @@ -526,7 +561,7 @@ sub process_arguments(){ } if (defined $opt_M) { - if ($opt_M =~ /sendmail/ || $opt_M =~ /qmail/ || $opt_M =~ /postfix/ ) { + if ($opt_M =~ /^(sendmail|qmail|postfix|exim)$/) { $mailq = $opt_M ; }elsif( $opt_M eq ''){ $mailq = 'sendmail'; @@ -542,7 +577,7 @@ sub process_arguments(){ } sub print_usage () { - print "Usage: $PROGNAME [-w ] [-c ] [-W ] [-C ] [-M ] [-t ] [-v verbose]\n"; + print "Usage: $PROGNAME -w -c [-W ] [-C ] [-M ] [-t ] [-v verbose]\n"; } sub print_help () { @@ -558,7 +593,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 ] (default = sendmail)\n"; + print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n"; print "-h (--help)\n"; print "-V (--version)\n"; print "-v (--verbose) = debugging output\n"; -- cgit v1.2.3-74-g34f1