Last active
September 23, 2018 21:20
-
-
Save dev01d/64f35ff2e4696da50ace884c9cdf0a5a to your computer and use it in GitHub Desktop.
A script for monitoring Exim undelivered mail queue.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# A script for monitoring Exim undelivered mail queue. | |
# intended to be used in conjunction with a cron job. | |
# | |
# Email recipient | |
alertEmail=#Add email here. | |
# Set the alert threshold here | |
queueThreshold=100 | |
# result log location | |
resultLog="/tmp/mail-Queue.log" | |
# Variables | |
currentQueue="`exim -bpc`" | |
logTime=$(date) | |
if [ "$currentQueue" >= "$queueThreshold" ]; | |
then | |
echo "Mail Queue Threshold observed." > $resultLog | |
echo $logTime >> $resultLog | |
echo "Current queue is: $currentQueue" >> $resultLog | |
echo "Mail queue summary" >> $resultLog | |
echo "`exim -bp | exiqsumm -c`" >> $resultLog | |
# Optional search with greater detail to be used in lieu of preceding line. | |
#echo "`exim -bp | exipick -bpc <search term>`">> $resultLog | |
mail -s "Mail Queue Threshold observed for `hostname` : $currentQueue" $alertEmail < $resultLog | |
cat $alertEmail | |
exit | |
else | |
exit | |
fi | |
# Optional garbage collection because tmp is temp. | |
# Comment rm and uncomment cat for debugging alert mail send issues. | |
#cat $resultLog | |
rm $resultLog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment