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 root@hostname'"
/usr/sbin/exim -M "$_message_id"