summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/check_tcp.c2
-rw-r--r--plugins/netutils.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index bd7736b..f75c523 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -237,7 +237,7 @@ main (int argc, char **argv)
237 gettimeofday (&tv, NULL); 237 gettimeofday (&tv, NULL);
238 238
239 result = np_net_connect (server_address, server_port, &sd, PROTOCOL); 239 result = np_net_connect (server_address, server_port, &sd, PROTOCOL);
240 if (result == STATE_CRITICAL) return STATE_CRITICAL; 240 if (result == STATE_CRITICAL) return econn_refuse_state;
241 241
242#ifdef HAVE_SSL 242#ifdef HAVE_SSL
243 if (flags & FLAG_SSL){ 243 if (flags & FLAG_SSL){
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 83f8942..705aaf0 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -161,6 +161,10 @@ process_request (const char *server_address, int server_port, int proto,
161int 161int
162np_net_connect (const char *host_name, int port, int *sd, int proto) 162np_net_connect (const char *host_name, int port, int *sd, int proto)
163{ 163{
164 /* send back STATE_UNKOWN if there's an error
165 send back STATE_OK if we connect
166 send back STATE_CRITICAL if we can't connect.
167 Let upstream figure out what to send to the user. */
164 struct addrinfo hints; 168 struct addrinfo hints;
165 struct addrinfo *r, *res; 169 struct addrinfo *r, *res;
166 struct sockaddr_un su; 170 struct sockaddr_un su;
@@ -250,16 +254,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
250 else if (was_refused) { 254 else if (was_refused) {
251 switch (econn_refuse_state) { /* a user-defined expected outcome */ 255 switch (econn_refuse_state) { /* a user-defined expected outcome */
252 case STATE_OK: 256 case STATE_OK:
253 case STATE_WARNING: /* user wants WARN or OK on refusal */ 257 case STATE_WARNING: /* user wants WARN or OK on refusal, or... */
254 return econn_refuse_state; 258 case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */
255 break;
256 case STATE_CRITICAL: /* user did not set econn_refuse_state */
257 if (is_socket) 259 if (is_socket)
258 printf("connect to file socket %s: %s\n", host_name, strerror(errno)); 260 printf("connect to file socket %s: %s\n", host_name, strerror(errno));
259 else 261 else
260 printf("connect to address %s and port %d: %s\n", 262 printf("connect to address %s and port %d: %s\n",
261 host_name, port, strerror(errno)); 263 host_name, port, strerror(errno));
262 return econn_refuse_state; 264 return STATE_CRITICAL;
263 break; 265 break;
264 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 266 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
265 return STATE_UNKNOWN; 267 return STATE_UNKNOWN;