summaryrefslogtreecommitdiffstats
path: root/plugins/netutils.c
diff options
context:
space:
mode:
authorgcoxmoz <gcox@mozilla.com>2014-05-17 00:58:46 -0400
committergcoxmoz <gcox@mozilla.com>2014-05-17 00:58:46 -0400
commit0a89db746dfe930c4705f4a1cef007c1888799dd (patch)
tree71ac4c1aa866f06c576df7ac000607d28e3f63d4 /plugins/netutils.c
parenta3f0b96f32b9553bcf5e33b18e4637bfc6a12465 (diff)
downloadmonitoring-plugins-0a89db746dfe930c4705f4a1cef007c1888799dd.tar.gz
Update netutils.c
Return an encoded state rather than an explicit state if a connection failed.
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r--plugins/netutils.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index 00440465..f5e7dff2 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;
@@ -249,12 +253,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto)
249 else if (was_refused) { 253 else if (was_refused) {
250 switch (econn_refuse_state) { /* a user-defined expected outcome */ 254 switch (econn_refuse_state) { /* a user-defined expected outcome */
251 case STATE_OK: 255 case STATE_OK:
252 case STATE_WARNING: /* user wants WARN or OK on refusal */ 256 case STATE_WARNING: /* user wants WARN or OK on refusal, stay quiet */
253 return econn_refuse_state; 257 return STATE_CRITICAL;
254 break; 258 break;
255 case STATE_CRITICAL: /* user did not set econn_refuse_state */ 259 case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */
256 printf ("%s\n", strerror(errno)); 260 printf ("%s\n", strerror(errno));
257 return econn_refuse_state; 261 return STATE_CRITICAL;
258 break; 262 break;
259 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ 263 default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */
260 return STATE_UNKNOWN; 264 return STATE_UNKNOWN;