We had a problem with the nagios check_mailq plugin at work, it kept timing out. So I wrote a simple bash script (instead of 610 lines of perl) which is “compatible” with check_mailq (supports the same arguments) which uses “exim4” and is very quick. Just drop it in /usr/local/bin/check_mailq_simple.sh and adjust your nagios conf to use that instead of check_mailq
#!/bin/bash
WARNING=""
CRITICAL=""
MAILER=""
TIMER=""
while getopts "w:c:M:t" optionName; do
case "${optionName}" in
w) WARNING="${OPTARG}";;
c) CRITICAL="${OPTARG}";;
M) MAILER="${OPTARG}";;
t) TIMER="${OPTARG}";;
esac
done
MAILS_IN_QUEUE=`sudo /usr/sbin/exim4 -bpc`
if [[ ${MAILS_IN_QUEUE} -gt ${CRITICAL} ]]; then
echo "CRITICAL: mailq is ${MAILS_IN_QUEUE} (threshold w = ${CRITICAL})|unsent=${MAILS_IN_QUEUE};${WARNING};${CRITICAL};0"
exit 2
elif [[ ${MAILS_IN_QUEUE} -gt ${WARNING} ]]; then
echo "WARNING: mailq is ${MAILS_IN_QUEUE} (threshold w = ${WARNING})|unsent=${MAILS_IN_QUEUE};${WARNING};${CRITICAL};0"
exit 1
elif [[ ${MAILS_IN_QUEUE} -lt ${WARNING} ]]; then
echo "OK: mailq is ${MAILS_IN_QUEUE} (threshold w = ${WARNING})|unsent=${MAILS_IN_QUEUE};${WARNING};${CRITICAL};0"
exit
else
echo "ERROR: something did not go right"
exit 2
fi
This has been tested on Debian sarge.