From a3f0b96f32b9553bcf5e33b18e4637bfc6a12465 Mon Sep 17 00:00:00 2001 From: gcoxmoz Date: Sat, 17 May 2014 00:55:40 -0400 Subject: Update check_tcp.c Return the state asked for, if connection failed. --- plugins/check_tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 2714961f..0a6e2b27 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -238,7 +238,7 @@ main (int argc, char **argv) gettimeofday (&tv, NULL); result = np_net_connect (server_address, server_port, &sd, PROTOCOL); - if (result == STATE_CRITICAL) return STATE_CRITICAL; + if (result == STATE_CRITICAL) return econn_refuse_state; #ifdef HAVE_SSL if (flags & FLAG_SSL){ -- cgit v1.2.3-74-g34f1 From 0a89db746dfe930c4705f4a1cef007c1888799dd Mon Sep 17 00:00:00 2001 From: gcoxmoz Date: Sat, 17 May 2014 00:58:46 -0400 Subject: Update netutils.c Return an encoded state rather than an explicit state if a connection failed. --- plugins/netutils.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/netutils.c b/plugins/netutils.c index 00440465..f5e7dff2 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -161,6 +161,10 @@ process_request (const char *server_address, int server_port, int proto, int np_net_connect (const char *host_name, int port, int *sd, int proto) { + /* send back STATE_UNKOWN if there's an error + send back STATE_OK if we connect + send back STATE_CRITICAL if we can't connect. + Let upstream figure out what to send to the user. */ struct addrinfo hints; struct addrinfo *r, *res; struct sockaddr_un su; @@ -249,12 +253,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) else if (was_refused) { switch (econn_refuse_state) { /* a user-defined expected outcome */ case STATE_OK: - case STATE_WARNING: /* user wants WARN or OK on refusal */ - return econn_refuse_state; + case STATE_WARNING: /* user wants WARN or OK on refusal, stay quiet */ + return STATE_CRITICAL; break; - case STATE_CRITICAL: /* user did not set econn_refuse_state */ + case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ printf ("%s\n", strerror(errno)); - return econn_refuse_state; + return STATE_CRITICAL; break; default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ return STATE_UNKNOWN; -- cgit v1.2.3-74-g34f1 From f05e7016320f4671fbf86cc5abc277efea20f79e Mon Sep 17 00:00:00 2001 From: gcoxmoz Date: Sat, 17 May 2014 01:16:12 -0400 Subject: Patch against issue 1062 --- plugins/netutils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/netutils.c b/plugins/netutils.c index f5e7dff2..7ae97223 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -253,9 +253,7 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) else if (was_refused) { switch (econn_refuse_state) { /* a user-defined expected outcome */ case STATE_OK: - case STATE_WARNING: /* user wants WARN or OK on refusal, stay quiet */ - return STATE_CRITICAL; - break; + case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ printf ("%s\n", strerror(errno)); return STATE_CRITICAL; -- cgit v1.2.3-74-g34f1