Monday, 9 July 2012

Script to monitor exim mail queue

==> Features
* This particular script alerts the admin if the mail queue is larger than the specified limit
* Script for EXIM Mail Servers

==> Usage
* Copy the below code to a file and give it execute permission
Code:
$ chmod 755 [file_name]

* Set the code to run every 30 minutes by configuring it as a cron job
Code:
*/30 * * * * /bin/sh [/path/to/file] > /dev/null 2>&1

* Edit the variables under the section: "Edit here" to suit your requirements

==> Script
Code:
#!/bin/bash
# Script from www.r6host.com to alert admin about larger mail queue
# Save the file as eximqueue.sh

######### Edit here ##########

_mail_user=info@r6host.com # Set this to your email id to receive alerts on mail queue
_limit=200 # Set the limit here

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

clear;
_result="/tmp/eximqueue.txt"
_queue="`exim-bpc`"

if [ "$_queue" -ge "$_limit" ]; then
echo "Current queue is: $_queue" > $_result
echo "Summary of Mail queue" >> $_result
echo "`exim -bp | exiqsumm`" >> $_result
mail -s "Number of mails on `hostname` : $_queue" $_mail_user < $_result
cat $_result
fi

rm -f $_result

No comments:

Post a Comment