PDA

View Full Version : Monitoring your email queue (PHP)



ICEWARP_BRAZIL
04-17-2011, 10:05 PM
Some of you might have felt the need to monitor your inbound and outbound queue, to detect abnormal activity that may indicate spam or overload.

Monitoring software such as PRTG have sensors that let you monitor # of files in a network share.

However, I've been using this simple script in PHP, stored in IceWarp's html directory. You could schedule it in IceWarp's Tools/Tasks & Events and make it send you an email using PHP mail command if it reaches the specificied threshold.

I execute it every 10 min. and monitor it using PRTG to send me email if it reaches the defined threshold. I search for the word "Many".

Here's the code, hope it's useful for others. Of course, if you use MDA, change the path accordingly for incoming queue.

<?php

$dir_path = "c:/icewarp/temp/smtp/";
$count = count(glob($dir_path . "*"));

if($count >= 100){
//step 1
echo "Many files in SMTP IN (+100)! \n\n";
} else {
//step 2
echo "Not that much files in SMTP IN (less then 100), relax... :)<br><br>";
}
?>

<?php

$dir_path = "c:/icewarp/mail/_outgoing/";
$count = count(glob($dir_path . "*"));

if($count >= 100){
//step 1
echo "Many files in outbound queue! (+100) \n\n";
} else {
//step 2
echo "Not that much files in outbound queue (less then 100), relax... :)<br><br>";
}
?>

<?php

$dir_path = "c:/icewarp/mail/_outgoing/retry/";
$count = count(glob($dir_path . "*"));

if($count >= 1000){
//step 1
echo "Many files in outbound retry queue! (+1000) \n\n";
} else {
//step 2
echo "Not that much files in outbound retry queue (less then 1000), relax... :)<br><br>";
}
?>

All the best,
Flávio

eclipse4ever
01-04-2013, 11:58 AM
Thanks for your post above, just what I needed :)

This should be integrated in the system monitor of IceWarp!

Best Regards
Tim Hallgren