I was setting up monitoring of mail queues with the nagios plugin check_mailq and found it didn’t work on cPanel servers. Google led me to a few shell scripts that used sudo to run exim -bpc. I didn’t like that option so I dove into check_mailq, expecting to make a few changes to the code. Instead, I discovered that for exim, the check_mailq plugin expects to parse the input of a queue listing. From there, the solution was straight forward.
Edit nagios/utils.pm and set $PATH_TO_MAILQ = “/usr/sbin/exiqgrep”;
Add the nagios user to the mailnull group in /etc/group.
Add this to nrpe.cfg:
command[check_mailq]=/usr/local/nagios/libexec/check_mailq -w 100 -c 500 -M exim
Restart nrpe, and it works perfectly.