diff options
author | Greg Cox <gcox@fibbsbozza.local> | 2014-07-29 18:52:12 -0400 |
---|---|---|
committer | Greg Cox <gcox@fibbsbozza.local> | 2014-07-29 18:52:12 -0400 |
commit | 4273dd06ff3e52094d6b267d00e8c51dd74de364 (patch) | |
tree | 425d127da5dbec7013999ed01b469fc3f72992d9 /plugins/netutils.c | |
parent | f05e7016320f4671fbf86cc5abc277efea20f79e (diff) | |
parent | 6f3d5825b203b75aef8d68bf0d117e7a1a4c0616 (diff) | |
download | monitoring-plugins-4273dd06ff3e52094d6b267d00e8c51dd74de364.tar.gz |
Merge remote-tracking branch 'upstream/master'
Conflicts:
plugins/netutils.c
Diffstat (limited to 'plugins/netutils.c')
-rw-r--r-- | plugins/netutils.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c index 7ae97223..705aaf09 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
@@ -171,11 +171,12 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
171 | char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; | 171 | char port_str[6], host[MAX_HOST_ADDRESS_LENGTH]; |
172 | size_t len; | 172 | size_t len; |
173 | int socktype, result; | 173 | int socktype, result; |
174 | short is_socket = (host_name[0] == '/'); | ||
174 | 175 | ||
175 | socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; | 176 | socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; |
176 | 177 | ||
177 | /* as long as it doesn't start with a '/', it's assumed a host or ip */ | 178 | /* as long as it doesn't start with a '/', it's assumed a host or ip */ |
178 | if(host_name[0] != '/'){ | 179 | if (!is_socket){ |
179 | memset (&hints, 0, sizeof (hints)); | 180 | memset (&hints, 0, sizeof (hints)); |
180 | hints.ai_family = address_family; | 181 | hints.ai_family = address_family; |
181 | hints.ai_protocol = proto; | 182 | hints.ai_protocol = proto; |
@@ -255,7 +256,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
255 | case STATE_OK: | 256 | case STATE_OK: |
256 | case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ | 257 | case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ |
257 | case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ | 258 | case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ |
258 | printf ("%s\n", strerror(errno)); | 259 | if (is_socket) |
260 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); | ||
261 | else | ||
262 | printf("connect to address %s and port %d: %s\n", | ||
263 | host_name, port, strerror(errno)); | ||
259 | return STATE_CRITICAL; | 264 | return STATE_CRITICAL; |
260 | break; | 265 | break; |
261 | 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) */ |
@@ -264,7 +269,11 @@ np_net_connect (const char *host_name, int port, int *sd, int proto) | |||
264 | } | 269 | } |
265 | } | 270 | } |
266 | else { | 271 | else { |
267 | printf ("%s\n", strerror(errno)); | 272 | if (is_socket) |
273 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); | ||
274 | else | ||
275 | printf("connect to address %s and port %d: %s\n", | ||
276 | host_name, port, strerror(errno)); | ||
268 | return STATE_CRITICAL; | 277 | return STATE_CRITICAL; |
269 | } | 278 | } |
270 | } | 279 | } |