Notification if Mail Queue Manager pass 100 emails

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
You could cron run a script like the following:

Code:
#!/bin/bash
if [ `exim -bpc` -ge 100 ] 
then echo "Exim queue at `exim -bpc`" | /bin/mail -s "Exim queue" [email protected]
else
:
fi
The file could be called /root/eximqueue.sh and would need to be executable to run:

Code:
chmod +x /root/eximqueue.sh
You could then put it into /var/spool/cron/root file to run every 15 minutes using this command:

Code:
*/15 * * * * /root/eximqueue.sh
 
Last edited:
  • Like
Reactions: AzeDK

Diego.Vieira

Member
Jul 19, 2010
15
0
51
You could cron run a script like the following:

Code:
#!/bin/bash
if [ `exim -bpc` -ge 100 ] 
then echo "Exim queue at `exim -bpc`" | /bin/mail -s "Exim queue" [email protected]
else
:
fi
The file could be called /root/eximqueue.sh and would need to be executable to run:

Code:
chmod +x /root/eximqueue.sh
You could then put it into /var/spool/cron/root file to run every 15 minutes using this command:

Code:
*/15 * * * * /root/eximqueue.sh
Thanks a lot!
 

osirion

Well-Known Member
Jan 16, 2007
54
4
158
I tried the above script and its setup properly (cron / perms) but its not working. Anyone have something that would work? Im on CentOS...
 

osirion

Well-Known Member
Jan 16, 2007
54
4
158
I'm using one provided by my supplier, to move over to CSF is going to be a bit of a headache. Was hoping I could get a bash script going so long though
 

osirion

Well-Known Member
Jan 16, 2007
54
4
158
Managed to get my hands on this:

Code:
#!/bin/bash

######### Edit here ##########

[email protected] # Set this to your email id to receive alerts on mail queue
_limit=100 # Set the limit here

##############################

clear;
_result="/tmp/eximqueue.txt"
_queue="`exim -bpc`"

if [ "$_queue" -ge "$_limit" ]; then
echo "Current queue is: $_queue" > $_result
echo "Summary of Mail queue" >> $_result
echo "`exim -bp | exiqsumm`" >> $_result
mail -s "Number of mails on `hostname` : $_queue" $_mail_user < $_result
cat $_result
fi

rm -f $_result
Works like a charm. Now I just have one question for someone slightly more advanced than me. Assuming the queue has exploded with spam, above message will just be in the back of the queue - so we would want to force it to be sent before anything else essentially.
From my understanding, we can use the following to force delivery of one message:
Code:
/usr/sbin/exim  -M  email-id
Anyone here know how I could extract the email-id from the scripts mail function and then run the above command with it?
Something along the lines of:
Code:
_message_id = "'exiqgrep -f [email protected]'"
/usr/sbin/exim  -M  "$_message_id"
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,228
463
Assuming the queue has exploded with spam, above message will just be in the back of the queue - so we would want to force it to be sent before anything else essentially.
Hello :)

It should send out on the first delivery attempt instead of staying in the mail queue. The mail in the queue typically failed on the initial attempt to deliver the message.

Thank you.