Exim queue size - auto-mail to myself

ebizindia

Well-Known Member
Oct 13, 2005
123
8
168
Kolkata, India
cPanel Access Level
Root Administrator
Hi

I want to setup a cronjob to auto mail the Exim queue size to myself so that I can take suitable action if the queue becomes too large.

The following command works on the shell prompt but does not work from a shall script.

exim -bpc | mail -s'Exim queue size' [email protected]

When run from a shell script, it just sends a blank mail. The queue size is not being piped.

Also, I want to modify this to alert me only when the size goes above, say 5000 or some other number. How to do that?

Thanks in advance!
 

quietFinn

Well-Known Member
Feb 4, 2006
2,033
543
493
Finland
cPanel Access Level
Root Administrator
I created a file named Exim_queue_size and in that I have one line:
Code:
exim -bpc | mail -s'Exim queue size' [email protected]
(replaced the email address of course).

I made that file executable:
Code:
chmod +x Exim_queue_size
and executed it:
Code:
./Exim_queue_size
and I got the Exim queue size to my email.
 

ebizindia

Well-Known Member
Oct 13, 2005
123
8
168
Kolkata, India
cPanel Access Level
Root Administrator
I did just that and I am getting a blank email. The mail even responds with "Null message body, hope that's OK" :(

funny thing is - this command works on the shell prompt, but not from the script file.

Any clues to what could be wrong in my case?

I even tried this:
exim -bpc > stats | cat stats | mail -s'Exim queue size' [email protected]

Looks like mail is not taking the input from the piped data.
 

faisikhan

Well-Known Member
Dec 12, 2011
86
0
56
Islamabad, Pakistan
cPanel Access Level
Root Administrator
Hi,

Are you sure the location path for the exim script file is correctly entered into the cron jobs and try giving the full path to exim because it may probably be the path issue as well. For example the script can be like this:

#!/bin/sh
/usr/sbin/exim -bpc | mail -s'Exim queue size' [email protected]

and the cron entry will be like(Note: it will be executed after every two seconds):
*/2 * * * * sh /root/Exim_queue_size.sh

Also when you run the script, see the exim and server logs to get more help and clues, but try above and if still problem exists, get back to me :)