The following script sends an alert whenever the exim mail queue is greater than a certain threshold
#!/bin/bash if [ `/usr/sbin/exim -bpc` -ge 300 ]; then mail -s "Alert: There are over 300 Emails in the queue!" [email protected] <<EOF Server Hostname : `/bin/hostname -f` Mail IP's (If Any): `cat /etc/mailips` Current Mail Queue : `/usr/sbin/exim -bpc` Server IP : `/sbin/ifconfig | /bin/awk '/inet addr/{print substr($2,6)}'` Thanks, Support Team. EOF fi
Note:
1. Set the desired threshold value for the mail queue
2. Change the alert email from [email protected] to your email ID.
3. If you want the allert to be sent to multiple email addresses you can do so by separating the email ID’s with a comma “,”