From: Jan Willamowius Date: Thu, 27 Oct 2005 19:15:58 +0000 (+0000) Subject: new plugin to monitor Postfix mail queue X-Git-Tag: spong-2_8_0-beta3~8 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f1cd84c004daeb090b73c895e3d2731440631bc5;p=spong.git new plugin to monitor Postfix mail queue --- diff --git a/src/lib/Spong/Client/plugins/check_postqueue b/src/lib/Spong/Client/plugins/check_postqueue new file mode 100755 index 0000000..f75fd2a --- /dev/null +++ b/src/lib/Spong/Client/plugins/check_postqueue @@ -0,0 +1,37 @@ +# Register routine with plugin registery +$CHECKFUNCS{'postqueue'} = \&check_postqueue; + +# Postfix mailq check for mail servers. If checks the number of mail +# message queue against the $MAILQWARN AND $MAILQCRIT variables + +# $Id: check_postqueue,v 1.1 2005/10/27 19:15:58 willamowius Exp $ + +use Spong::SafeExec qw(safe_exec); + +use File::Basename; + +sub check_postqueue { + my($mqcnt, $message, $color, $summary ); + + $singlq = 0; + my @msg = safe_exec($POSTQUEUE); + $mqcnt = 0; + while ($_ = shift @msg) { + $message .= $_; + if (/in (\d+) Requests\./) { $mqcnt = $1; } + next if (/^-/); + next if (length($_) < 4); + } + + $color = "green"; + if ($mqcnt > $MAILQWARN) { $color = "yellow"; } + if ($mqcnt > $MAILQCRIT) { $color = "red"; } + $summary = "Postfix mail queue count = $mqcnt"; + + &debug("postqueue - $color, $summary"); + &status( $SPONGSERVER, $HOST, "postqueue", $color, $summary, $message ); +} + +# I'm include perl code, I need this line. +1; +