aboutsummaryrefslogtreecommitdiff
path: root/plugins/netutils.c
diff options
context:
space:
mode:
authorGravatar Jeremy T. Bouse <undrgrid@users.sourceforge.net> 2003-03-16 23:28:49 +0000
committerGravatar Jeremy 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 @@
#include "netutils.h"
int socket_timeout = DEFAULT_SOCKET_TIMEOUT;
+int econn_refuse_state = STATE_CRITICAL;
+int was_refused = FALSE;
/* handles socket timeouts */
void
@@ -275,8 +277,22 @@ my_connect (char *host_name, int port, int *sd, int proto)
/* attempt to open a connection */
result = connect (*sd, res->ai_addr, res->ai_addrlen);
- if (result == 0)
+ if (result == 0) {
+ was_refused = FALSE;
break;
+ }
+
+ if (result < 0) {
+ switch (errno) {
+ case ECONNREFUSED:
+ switch (econn_refuse_state) {
+ case STATE_OK:
+ case STATE_WARNING:
+ was_refused = TRUE;
+ }
+ break;
+ }
+ }
close (*sd);
res = res->ai_next;
@@ -286,6 +302,8 @@ my_connect (char *host_name, int port, int *sd, int proto)
if (result == 0)
return STATE_OK;
+ else if (was_refused)
+ return econn_refuse_state;
else {
printf ("%s\n", strerror(errno));
return STATE_CRITICAL;