check_smtp

Thomas Guyot-Sionnest dermoth at aei.ca
Wed Feb 4 09:12:31 CET 2015


On 02/02/15 04:51 PM, Gareth Fletcher wrote:
> SMTP's criticality is usually in availability, not performance (nobody notices 0.25 vs 1sec delay). IMHO you should stick with seconds, but tweak max check attempts, make sure you have load balanced SMTP, check each node, check end-end mail, etc.
>
> In saying that, even check_tcp uses seconds for warning/critical thresholds.
>
> So if you want finer, you'd need to write a custom plugin :)

check_tcp has been supporting sub-second thresholds for quite some time...

> plugins/check_tcp -H www.aei.ca -p 80 -w 0.01 -c 0.05
> TCP WARNING - 0.011 second response time on port
> 80|time=0.010762s;0.010000;0.050000;0.000000;10.000000

It's easy to mimic check_smtp's behavior using check_tcp, as long as
you're not trying to use the STARTTLS command (SMTPS OTOH should work
with the -S / --ssl switch):

> check_tcp -H mail.aei.ca -p 25 -s 'EHLO localhost' -e '220 ' -w 0.02
> -c 0.05
> TCP WARNING - 0.020 second response time on port 25 [220
> mail002.contact.net
> ESMTP]|time=0.020276s;0.020000;0.050000;0.000000;10.000000

Note the deliberate space after '220 '... Using SMTPS:

> check_tcp -H smtp.gmail.com -p 465 -S -s 'EHLO localhost' -e '220 ' -w
> 0.1 -c 0.2
> TCP WARNING - 0.149 second response time on port 465 [220
> mx.google.com ESMTP g51sm1073069qgf.18 -
> gsmtp]|time=0.148505s;0.100000;0.200000;0.000000;10.000000

With -E instead of -e, you can use C escapes as well ("\r\n", etc.) so
you could even write all the command to send a test email and look for
the final 220 response (you'll have to get more that just "220 ", based
on what your mail server actually says...)

I deliberately set thresholds that return warnings in these examples to
how the fractions are being taken into account.

Regards,

-- 
Thomas





More information about the Help mailing list