aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.org> 2015-10-02 19:54:31 +0200
committerGravatar Sven Nierlein <sven@nierlein.org> 2015-10-02 19:54:31 +0200
commit0be10c669ec6d0b5338a274e59f1f964ec702edc (patch)
tree614c47ba80421bbcb5feb16cbf4ece5357b9e39d /plugins
parent9c32acf5bbb00e1073fba44745fa1d7aee94c8b2 (diff)
parent4273dd06ff3e52094d6b267d00e8c51dd74de364 (diff)
downloadmonitoring-plugins-0be10c669ec6d0b5338a274e59f1f964ec702edc.tar.gz
Merge pull request #1257 from gcoxmoz/master
check_tcp: Fixing to return desired exit code
Diffstat (limited to 'plugins')
-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 a18c37ae..5c563d80 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -237,7 +237,7 @@ main (int argc, char **argv)
gettimeofday (&tv, NULL);
result = np_net_connect (server_address, server_port, &sd, PROTOCOL);
- if (result == STATE_CRITICAL) return STATE_CRITICAL;
+ if (result == STATE_CRITICAL) return econn_refuse_state;
#ifdef HAVE_SSL
if (flags & FLAG_SSL){
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 83f8942f..705aaf09 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -161,6 +161,10 @@ process_request (const char *server_address, int server_port, int proto,
int
np_net_connect (const char *host_name, int port, int *sd, int proto)
{
+ /* send back STATE_UNKOWN if there's an error
+ send back STATE_OK if we connect
+ send back STATE_CRITICAL if we can't connect.
+ Let upstream figure out what to send to the user. */
struct addrinfo hints;
struct addrinfo *r, *res;
struct sockaddr_un su;
@@ -250,16 +254,14 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
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 */
+ case STATE_WARNING: /* user wants WARN or OK on refusal, or... */
+ case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */
if (is_socket)
printf("connect to file socket %s: %s\n", host_name, strerror(errno));
else
printf("connect to address %s and port %d: %s\n",
host_name, port, strerror(errno));
- return econn_refuse_state;
+ return STATE_CRITICAL;
break;
default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
return STATE_UNKNOWN;