always remember

Nothing is foolproof to a sufficiently talented fool... Make something
idiot proof, and the world will simply make a bigger idiot.

Monitor PostFix Outbound Mail Queue + Email

Here we’ve got a very small, but effective script that alerts when a PostFix queue grows beyond a predefined limit. In my environment, PostFix is being used by an outbound relay. This script can work in tandem with my other mail queue monitoring script (Exim Mail Queue Monitor).

#!/bin/bash
######### Edit here ##########

_mail_user=serverlogs@vooclients.com
_limit=400

##############################

clear;
_result="/tmp/postfixqueue.txt"
_queue="`find /var/spool/postfix/deferred -type f | wc -l`"

if [ "$_queue" -ge "$_limit" ]; then
echo "Current number of mails in the outbound queue: $_queue (Threshold is set at '$_limit')" > $_result
#echo "Summary of Mail queue" >> $_result
#echo "`exim -bp | exiqsumm`" >> $_result
mail -s "ALERT! Number of Mails in Outbound Queue on ESVA1: $_queue" $_mail_user < $_result
#cat $_result
fi

echo "Current number of mails in the outbound queue: $_queue (Threshold is set at $_limit)" > $_result
cat $_result
rm -f $_result

-Check monitors the “deferred” queue in PostFix. essentially everything that the relay could not process in that specific moment of time. If you have a spam outbreak, this queue will NOT be empty.

dave / February 20, 2016 / Code, Linux Bash
Tags: , , , ,