Checking Postfix queue size with Nagios

monitoringnagiospostfix

I need to check the number of mails in active queue on various Postfix installations, as a Nagios alert.

My first idea is to write a small Nagios plugin that SSHs to the Postfix server and read the value that I obtain through another little script. Then, Nagios will check this value against its warning and critical levels, as set up.

Is this approach what you'd call correct? Or doing through SSH is "too much"? Should I use the 5666/tcp Nagios port instead? (if yes, I did not find any example about yet)

Best Answer

Don't reinvent the wheel.

There are several "queue" checks posted on Nagios Exchange. For example: check_postfix_queue.

To use any of these as actove checks, you will need an agent of some sort. You can use NRPE, check_by_ssh, check_mk, etc., or you could even plumb it into snmpd if you were motivated (don't do that).

NRPE has a lower overhead than using ssh sessions, but the security of check_by_ssh is arguably a bit better, because you use SSH keys instead of just restricting it by IP. Whether or not this is important depends on your particular setup; if you have a private/out-of-band monitoring network, NRPE is fine. If you're checking over the Internets, check_by_ssh might be better.