The Return of Mailping

It was, I believe, at USENIX ’05 that I first heard about Mailping, a utility that would send an email message, check for its receipt, and report on the health of your mail system. Unfortunately, the utility had fallen into disrepair, and I couldn’t find an alternative.

So I did what any hacker would do: I wrote my own.

I wrote mine with [Nagios|http://www.nagios.org] in mind; the goal of my version of Mailping was to add it as a service check to Nagios. The checks that come with Nagios are remarkably weak: you can check if SMTP is receiving requests, but not if it’s actually sending them. This only notifies you when your mail server is pinin’ for the fjords, not for a simple misconfiguration (or if another component is down.) The IMAP and POP checks are even worse; they just see if ports are open, without trying to login or anything like that.

Mailping remedies these problems by opening an SMTP connection, authenticating if necessary (i.e., if you’re using SASL), and sending a message to a predetermined mailbox. It then logs in via IMAP (IMAPS is also supported) to check that mailbox and reports the time it took for each message to make its trip. It does __not__ block while waiting for messages, so it’s perfect for Nagios.

It does not currently support POP (which we don’t use), but if someone wanted to add that functionality, I’d be happy to add your changes to the script itself.

Mailping uses a magic string in the subject line of emails it sends to keep its messages separate from anything else that mailbox receives, but you still might want to use a mailbox that’s either dedicated to Mailping or receives no other important mail; we use an account that’s generally devoted to testing all sorts of things.

For those of you who read [last week’s blog entry|https://lopsa.org/node/601], it also integrates nicely with NagiosGraph. The following stanza in your map file will do the trick:

{{{
# Service type: mailping
# output:OK: All email received
# perfdata:trip=60
/perfdata:trip=(d+)/
and push @s, [ trip,
[ ‘trip_time’, GAUGE, $1 ],
];
}}}

You can then configure Nagios to run Mailping every minute and warn you if mail takes longer than a certain amount of time. Generally, I like it to warn me if mail takes 7 minutes and go critical if it takes 10; during busy times of the year, though, it’s more realistic to warn at 10 minutes and go critical at 15.

You can find Mailping at [http://www.nebrwesleyan.edu/people/stpierre/mailping.pl].