Not receiving expected strings in check_smtp should always be critical

Grant Byers <[email protected]>
Newsgroups gmane.network.nagios.plugins.devel
Message-ID <CANJMdcbS=os1JycriDuoDv6bj9XyV-N_Sx4LSVXeXnkppAkSnw@mail.gmail.com>
Hi,

When check_smtp first connects to the SMTP server, we expect a 220 (or
whatever we specify with -e). On subsequent commands specified with -C, we
expect the strings passed in -R. For example ;

$ /usr/lib/nagios/plugins/check_smtp -v -H ... -C "MAIL FROM: <...>" -R 250
HELOCMD: HELO ...
220 ... Microsoft ESMTP MAIL Service ready at Mon, 19 Mar 2012 11:52:18
+1000
250 2.1.0 Sender OK

IMO, anything other than what is expected should be CRITICAL, not WARNING.

I would expect that in most 24x7 environments where admins receive alerts
via SMS, people will configure SMS contact notification options to not
include warning levels. You only want to be woken up when a service is
critical. ie. service_notification_options c,r. Obviously, you could create
a second contact that receives SMS on warning & use that for the SMS
service, but this doesn't fit well with other checks. If a service is not
behaving as expected, i'd say this is critical.

The attached patch is a quick hack to ensure at least these conditions are
critical. YMMV.

Regards,
Grant

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure

_______________________________________________________
Nagios Plugin Development Mailing List Nagiosplug-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
::: Please include plugins version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null
check_smtp.c.critical_unless_expected.diff (application/octet-stream, 607 B)
--- check_smtp.c.orig	2012-03-19 12:11:30.196852791 +1000
+++ check_smtp.c	2012-03-19 12:14:11.540863400 +1000
@@ -197,7 +197,7 @@
 				else
 					printf (_("Invalid SMTP response received from host on port %d: %s\n"),
 									server_port, buffer);
-				result = STATE_WARNING;
+				result = STATE_CRITICAL;
 			}
 		}
 
@@ -316,7 +316,7 @@
 					result = STATE_OK;
 				}
 				else if (excode == REG_NOMATCH) {
-					result = STATE_WARNING;
+					result = STATE_CRITICAL;
 					printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]);
 				}
 				else {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.