When you run exim mail server, it is good to keep an eye on number of emails in mail queue. here is a PHP script that will check number of emails in queue, if it exceed pre-set number, it will email you.
Create file
mkdir /usr/serverok/ vi /usr/serverok/mail_q_monitor.php
Add following content.
$alertOn) { $hostname = exec('/bin/hostname'); $subject = 'Mail queue alert on ' . $hostname; $mail_text = 'Mail queue on server ' . $hostname . ' have ' . $num_mails . ' mails'; mail($adminEmail, $subject, $mail_text); }
In this case, if mails in queue exceeded 100, you get email.
$alertOn = 100;
You can change 100 to whatever number you need.
$adminEmail = "[email protected]";
Replace [email protected] with your email address.
Set script to run every 10 minutes using cronjob
*/10 * * * * /usr/local/bin/php /usr/serverok/mail_q_monitor.php >/dev/null 2>&1
Leave a Reply