Saturday 13 September 2014

Mail queue alert script for cPanel server via email

We need to monitor our server mail queue for cPanel servers, Possible outgoing spam as well as to maintain the server performance. Often large mail queue causes server overloading issues. It is very easy to get an alert if your server mail queue contains more than X  numbers of mails. You can use the following script to monitor your server mail queue for your cPanel servers:




#!/bin/bash
# use: Bash Shell script to monitor or Check Mail queue


EMAIL=”your email address”

MQUEUE=`find /var/spool/exim/input -name ‘*-H’ | wc -l | sed -e “s/ //g”`

if [ $MQUEUE -gt XXX ]; then
echo “Mail queue at `hostname` has $MQUEUE messages!!!” | mail -s “MAIL QUEUE ALERT: Mail queue for `hostname`” $EMAIL
fi

No comments:

Post a Comment