From f1cd84c004daeb090b73c895e3d2731440631bc5 Mon Sep 17 00:00:00 2001 From: Jan Willamowius Date: Thu, 27 Oct 2005 19:15:58 +0000 Subject: [PATCH] new plugin to monitor Postfix mail queue --- src/lib/Spong/Client/plugins/check_postqueue | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 src/lib/Spong/Client/plugins/check_postqueue 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; + -- 2.30.2