hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Hosting Security and Technology Tutorials : Guide: Recieve An Email when your Mail Queue gets large
Closed Thread

Hosting Security and Technology Tutorials Tutorials related to server security or the like.
Forum Jump

Guide: Recieve An Email when your Mail Queue gets large

Closed Thread Post New Thread In Hosting Security and Technology Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 02-12-2006, 08:11 PM
ub3r ub3r is offline
Disabled
 
Join Date: Dec 2002
Location: chica go go
Posts: 11,858
*

Guide: Recieve An Email when your Mail Queue gets large


On a few servers i monitor, there is an ongoing problem of the email queue building up to ridiculous sizes. So, I wrote a script which checks the mail queue size every 5 minutes, and sends me an email if the queue is larger than 500 messages.

Open up your favorite text editor, and paste this code in there:

PHP Code:
<?
        $exec 
system('exim -bpc');
        
$time date("F j, Y, g:i a");
        if(
$exec >= 800)
        {
                
mail("you@yourdomain.com""big mail queue alert""It is $time, and the  mail queue currently has $exec messages in it""From: mailcheck@yourdomain.com");
        }
        else{
                die(
"nothing to see here");
        }
?>
Change you@yourdomain.com to whatever your email address is. You can also change "800" to whatever value you want.. 100, 1000, any numerical value you want.

Save the file as mailcheck.php, and stick it in your home directory. eg: /root/mailcheck.php . Depending on your server, you may need to execute as root.

Next, create a cron job for the script by typing the following command as root:

crontab -e

After that, it will open your favorite text editor with your crontab. At the bottom of that file, add this:


Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * php /path/to/your/mailcheck.php > /dev/null
Then save the file, and it will write the file off to your crontab. After that, there's nothing else to do. It will check the size of your mail queue every 5 minutes, and if the queue is bigger than the specified size (default: 800 messages), it will shoot an email off to you with the time, and the size of the mail queue.



Sponsored Links
  #2  
Old 05-07-2006, 01:13 PM
bear bear is offline
Community Leader
 
Join Date: Oct 2002
Location: cognito
Posts: 17,439
Simpler way to get every 5 minutes:
Code:
*/5 * * * * php /path/to/your/mailcheck.php > /dev/null
And since this thread is several months old, I'll close it.

Closed Thread

Related posts from TheWhir.com
Title Type Date Posted
Outbound Spam Causing Sleepless Nights? Blog 2013-05-13 09:52:21
Web Host SoftLayer Launches Message Queue Service for Scalable Software System Communication Web Hosting News 2012-09-13 17:26:30
Web Hosting Control Panel cPanel and WHM Version 11.32 Adds Features, Fixes Web Hosting News 2012-04-08 11:51:35
cPanel Launches Version 11.32 of Control Panel and Web Host Manager Web Hosting News 2012-02-15 12:46:33
Email Provider OpenXchange Partners with Openwave Web Hosting News 2011-10-12 17:23:08


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?