summaryrefslogtreecommitdiffstats
path: root/plugins/netutils.c
diff options
context:
space:
mode:
authorJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-03-16 23:28:49 +0000
committerJeremy T. Bouse <undrgrid@users.sourceforge.net>2003-03-16 23:28:49 +0000
commit33cce285cbfd1d7ca79f2369f9bb735c1720e673 (patch)
tree51d498383281604bfb411a7a91b06f6d76270f17 /plugins/netutils.c
parentdf6b0771cde1accb4f7d11fd6ab5829b1e03003d (diff)
downloadmonitoring-plugins-33cce285cbfd1d7ca79f2369f9bb735c1720e673.tar.gz
Applied patch #660973 for tcp refusals
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@426 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r--plugins/netutils.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 4234c436..b3348d6e 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -32,6 +32,8 @@
32#include "netutils.h" 32#include "netutils.h"
33 33
34int socket_timeout = DEFAULT_SOCKET_TIMEOUT; 34int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
35int econn_refuse_state = STATE_CRITICAL;
36int was_refused = FALSE;
35 37
36/* handles socket timeouts */ 38/* handles socket timeouts */
37void 39void
@@ -275,8 +277,22 @@ my_connect (char *host_name, int port, int *sd, int proto)
275 /* attempt to open a connection */ 277 /* attempt to open a connection */
276 result = connect (*sd, res->ai_addr, res->ai_addrlen); 278 result = connect (*sd, res->ai_addr, res->ai_addrlen);
277 279
278 if (result == 0) 280 if (result == 0) {
281 was_refused = FALSE;
279 break; 282 break;
283 }
284
285 if (result < 0) {
286 switch (errno) {
287 case ECONNREFUSED:
288 switch (econn_refuse_state) {
289 case STATE_OK:
290 case STATE_WARNING:
291 was_refused = TRUE;
292 }
293 break;
294 }
295 }
280 296
281 close (*sd); 297 close (*sd);
282 res = res->ai_next; 298 res = res->ai_next;
@@ -286,6 +302,8 @@ my_connect (char *host_name, int port, int *sd, int proto)
286 302
287 if (result == 0) 303 if (result == 0)
288 return STATE_OK; 304 return STATE_OK;
305 else if (was_refused)
306 return econn_refuse_state;
289 else { 307 else {
290 printf ("%s\n", strerror(errno)); 308 printf ("%s\n", strerror(errno));
291 return STATE_CRITICAL; 309 return STATE_CRITICAL;