diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-03-01 12:27:19 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-03-01 12:27:19 +0000 |
commit | 3c81964713e4114d7f40f95e9373c24b596d1efd (patch) | |
tree | 4c735cf76d5b94e246d60afb79969476379d9919 /plugins/netutils.c | |
parent | f7c1eca1c45f77df548e426281569e0c7c0a6480 (diff) | |
download | monitoring-plugins-3c81964713e4114d7f40f95e9373c24b596d1efd.tar.gz |
check_tcp was returning uninitialized string with user-defined refused outcome
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@833 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r-- | plugins/netutils.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c index 5017eb9e..1fa69a35 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -252,11 +252,7 @@ my_connect (const char *host_name, int port, int *sd, int proto) if (result < 0) { switch (errno) { case ECONNREFUSED: - switch (econn_refuse_state) { - case STATE_OK: - case STATE_WARNING: - was_refused = TRUE; - } + was_refused = TRUE; break; } } @@ -269,8 +265,21 @@ my_connect (const char *host_name, int port, int *sd, int proto) if (result == 0) return STATE_OK; - else if (was_refused) - return econn_refuse_state; + 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; + break; + case STATE_CRITICAL: /* user did not set econn_refuse_state */ + printf ("%s\n", strerror(errno)); + return econn_refuse_state; + break; + default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ + return STATE_UNKNOWN; + break; + } + } else { printf ("%s\n", strerror(errno)); return STATE_CRITICAL; |