DiagramNagios plugin: Mail Flow Checker

Nagios plugin to test a complete mail-flow: One script sends a mail to the specified recipient, and records the time. Another script picks up mail from a designated IMAP mailbox and parses the time of mail-arrival in the mail's headers. A Nagios check script reports on the data recorded by the two other scripts.

Several mail-flows may be monitored this way.

Files to download and place somewhere where Nagios can read the files:

The .ddl file is used to populate a local PostgreSQL database. Make sure the "nagios" user is allowed to connect to the database (using OS authentication).

If the very first step of the mail-chain (submitting the outgoing mail) fails, this is not recorded; so that will not generate an alarm. Consequently, this Nagios plugin should be supplemented with use of the ordinary check_smtp and check_imap plugins.

Note: The plugin assumes that the receiving mail-server's clock is correct.

The plugin yields performance data, so graphs may be built from it. An example: Mail delivery times

Python modules which are required:

Currently, the scripts only support connecting to a local PostgreSQL server, as there is no way to indicate username/password.

Remember to make the three scripts executable:
chmod +x mail_flow_checker mail_flow_receiver mail_flow_sender

For user nagios, set the following in crontab, adjusted for where you put the scripts and configuration file(s):

*/3 * * * * /usr/local/nagios/mail_flow_receiver -C /usr/local/nagios/mail_flow-someSMTPserver-to-someIMAPserver.cfg
*/3 * * * * /usr/local/nagios/mail_flow_receiver -C /usr/local/nagios/mail_flow-someOtherSMTPserver-to-someIMAPserver.cfg
*/10 * * * * /usr/local/nagios/mail_flow_sender -C /usr/local/nagios/mail_flow-someSMTPserver-to-someIMAPserver.cfg
*/10 * * * * /usr/local/nagios/mail_flow_sender -C /usr/local/nagios/mail_flow-someOtherSMTPserver-to-someIMAPserver.cfg