summaryrefslogtreecommitdiffstats
path: root/plugins/netutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r--plugins/netutils.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 5017eb9..1fa69a3 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)
252 if (result < 0) { 252 if (result < 0) {
253 switch (errno) { 253 switch (errno) {
254 case ECONNREFUSED: 254 case ECONNREFUSED:
255 switch (econn_refuse_state) { 255 was_refused = TRUE;
256 case STATE_OK:
257 case STATE_WARNING:
258 was_refused = TRUE;
259 }
260 break; 256 break;
261 } 257 }
262 } 258 }
@@ -269,8 +265,21 @@ my_connect (const char *host_name, int port, int *sd, int proto)
269 265
270 if (result == 0) 266 if (result == 0)
271 return STATE_OK; 267 return STATE_OK;
272 else if (was_refused) 268 else if (was_refused) {
273 return econn_refuse_state; 269 switch (econn_refuse_state) { /* a user-defined expected outcome */
270 case STATE_OK:
271 case STATE_WARNING: /* user wants WARN or OK on refusal */
272 return econn_refuse_state;
273 break;
274 case STATE_CRITICAL: /* user did not set econn_refuse_state */
275 printf ("%s\n", strerror(errno));
276 return econn_refuse_state;
277 break;
278 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
279 return STATE_UNKNOWN;
280 break;
281 }
282 }
274 else { 283 else {
275 printf ("%s\n", strerror(errno)); 284 printf ("%s\n", strerror(errno));
276 return STATE_CRITICAL; 285 return STATE_CRITICAL;