Exim Mailqueue Monitoring Script

This script will count number of mails in queue and validate with threshold value.
If it is more than it will send an email using thirdparty tool called SendEmail.
One important point to note, that is we need to use SMTP hosted on other server. Thats why we are using SendEmail perl script.
We need to run this script after certain period using CronJobs.

Download latest version of SendEmail perl script from : http://caspian.dotconf.net/menu/Software/SendEmail/

Extract and copy content under /opt/sendEmail/

And use below script

#!/bin/bash

EMAIL=<EMAIL ADDRESS Which you want to be notified>
HOSTNAM=`hostname`
QSIZE="200"

MQ=`find /var/spool/exim/input -name '*-H' | wc -l 1| sed -e "s/ //g"`

if [ "$MQ" -gt "$QSIZE" ]
then
echo “There are $MQ messages in Mail Queue!” | /opt/sendEmail/sendEmail.pl -f <FROM EMAIL ADDRESS>;; -t $EMAIL -u "MAIL QUEUE ALERT: Mail queue for $HOSTNAM" -s <SMTP SERVER:PORT>; -xu <SERVER USERNAME> -xp <PASSWORD> -o tls=no
fi

Neelesh Gurjar has written 115 articles

Leave a Reply