Header RSS Feed
 
If you only want to see the articles of a certain category, please click on the desired category below:
ALL Android Backup BSD Database Hacks Hardware Internet Linux Mail MySQL Monitoring Network Personal PHP Proxy Shell Solaris Unix Virtualization VMware Windows Wyse

How to monitor qmail mail queue (check_mailq alternative)
Monday - Apr 29th 2013 - by - (2 comments)

Although the official Nagios plugin check_mailq has a special -M (for MTA) switch where qmail can be used as option, it still cannot really handle the qmail mail queue. I even added the correct location of qmail-qstat into utils.pm, but I still wasn't able to monitor the mail queue on a specific qmail mail server.

To be able to monitor the qmail mail queue, I made the following steps:

1. Backed up the original check_mailq plugin and created a new check_mailq:

#!/bin/bash
#########################################
# special check_mailq for qmail by claudio kuenzler
# 2013-04-18 Created script
# 2014-05-07 Bugfix in getopt
#########################################

# Check for people who need help - aren't we all nice ;-)
#########################################################################
if [ "${1}" = "--help" -o "${#}" = "0" ];
       then
       echo -e "Wrong option given. Use -w and -c";
       exit 1;
fi

# Get user-given variables
#########################################################################
while getopts "w:c:" Input;
do
       case ${Input} in
       w)      warning=${OPTARG};;
       c)      critical=${OPTARG};;
       *)      echo "Wrong option given. Use -w and -c"
               exit 1
               ;;
       esac
done

mailq=$(/var/qmail/bin/qmail-qstat | sed -n '1p' | awk -F': ' '{print $2}')

if [[ $mailq -gt $warning ]]
then echo "MAILQ CRITICAL - $mailq mails in queue|qmailq=$mailq;$warning;$critical"; exit 2
elif [[ $mailq -gt $critical ]]
then echo "MAILQ WARNING - $mailq mails in queue|qmailq=$mailq;$warning;$critical"; exit 1
elif [[ $mailq -le 0 ]]
then echo "MAILQ UNKNOWN - $mailq mails in queue cant really be..."; exit 3
else echo "MAILQ OK - $mailq mails in queue|qmailq=$mailq;$warning;$critical"; exit 0
fi

echo "MAILQ UNKNOWN - Should never come here"
exit 3


2. Add nrpe user to the group qmail.

In my case this was the user "daemon", which can be verified like this:

ps aux | grep nrpe
daemon   12042  0.0  0.0  39980  1080 ?        Ss   Apr03   0:19 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -d

usermod -a -G qmail daemon


 

Add a comment

Show form to leave a comment

Comments (newest first):

ck from Switzerland wrote on May 7th, 2014:
Thanks, BlackJack. I have added the second colon after c (to expect a value).

BlackJack wrote on May 7th, 2014:
There is a colon missing in the first getopt argument. It should read … getopts "w:c:" ….


Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

6937 Days
until Death of Computers
Why?