• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

Mail Exploit Warning Script

N

nickbrown

Guest
We had a need to monitor the number of emails in the qMail mail queue. I wrote the following shell script to email you when your mail queue meets a threshold.

The best way to determine what to set the threshold at is to check the number of emails in the queue every few hours over a 2-3 day period. Allow for a spike of upto 100-200 emails then there is your magic number. You can check the number of emails in your queue by running /var/qmail/bin/qmail-qstat

We set our threshold at 1000.

Code:
cd /var/qmail
messfiles=`find queue/mess/* -print | wc -w`
MIQ="$messfiles"
QUOTA="1000"
HOST="`hostname`"
if [ $MIQ -lt $QUOTA ]
then
        echo ""
else
        echo "Warning - $MIQ mails in queue on $HOST" | mail -s "EXPLOIT WARNING - Mail Queue" [email][email protected][/email]
fi

All you need to do is set the Quota variable to your desired warning threshold, and change the email address in the mail string.

Throw this in the Cron and run it as often as you feel necessary. We run it every 10 minutes.

Don't hesitate to drop me a PM if you need help

Edit. I should note I have tested this on Plesk 7.5 and Plesk 8 for Linux. I will release a Windows version when I get time to do it.

Cheers
Nick :)
 
Back
Top