diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-13 00:43:46 +0100 |
|---|---|---|
| committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-13 00:43:46 +0100 |
| commit | 44e4e467c678d481dfc74ade1beb47e199ea67dd (patch) | |
| tree | 0dae09ee320a47996d0d85ba8166ef45320e0214 | |
| parent | d5ed6a2d8f3f3f388e5d1f2f7a8fc3ee2c9b6007 (diff) | |
| download | monitoring-plugins-44e4e467c678d481dfc74ade1beb47e199ea67dd.tar.gz | |
Do not print on failed network connections
| -rw-r--r-- | plugins/netutils.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c index ee81912a..5f118a9e 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c | |||
| @@ -177,7 +177,7 @@ int np_net_connect(const char *host_name, int port, int *sd, int proto) { | |||
| 177 | result = getaddrinfo(host, port_str, &hints, &res); | 177 | result = getaddrinfo(host, port_str, &hints, &res); |
| 178 | 178 | ||
| 179 | if (result != 0) { | 179 | if (result != 0) { |
| 180 | printf("%s\n", gai_strerror(result)); | 180 | // printf("%s\n", gai_strerror(result)); |
| 181 | return STATE_UNKNOWN; | 181 | return STATE_UNKNOWN; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| @@ -187,7 +187,7 @@ int np_net_connect(const char *host_name, int port, int *sd, int proto) { | |||
| 187 | *sd = socket(r->ai_family, socktype, r->ai_protocol); | 187 | *sd = socket(r->ai_family, socktype, r->ai_protocol); |
| 188 | 188 | ||
| 189 | if (*sd < 0) { | 189 | if (*sd < 0) { |
| 190 | printf("%s\n", _("Socket creation failed")); | 190 | // printf("%s\n", _("Socket creation failed")); |
| 191 | freeaddrinfo(r); | 191 | freeaddrinfo(r); |
| 192 | return STATE_UNKNOWN; | 192 | return STATE_UNKNOWN; |
| 193 | } | 193 | } |
| @@ -237,10 +237,11 @@ int np_net_connect(const char *host_name, int port, int *sd, int proto) { | |||
| 237 | case STATE_OK: | 237 | case STATE_OK: |
| 238 | case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ | 238 | case STATE_WARNING: /* user wants WARN or OK on refusal, or... */ |
| 239 | case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ | 239 | case STATE_CRITICAL: /* user did not set econn_refuse_state, or wanted critical */ |
| 240 | if (is_socket) | 240 | if (is_socket) { |
| 241 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); | 241 | // printf("connect to file socket %s: %s\n", host_name, strerror(errno)); |
| 242 | else | 242 | } else { |
| 243 | printf("connect to address %s and port %d: %s\n", host_name, port, strerror(errno)); | 243 | // printf("connect to address %s and port %d: %s\n", host_name, port, strerror(errno)); |
| 244 | } | ||
| 244 | return STATE_CRITICAL; | 245 | return STATE_CRITICAL; |
| 245 | break; | 246 | break; |
| 246 | default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ | 247 | default: /* it's a logic error if we do not end up in STATE_(OK|WARNING|CRITICAL) */ |
| @@ -248,10 +249,11 @@ int np_net_connect(const char *host_name, int port, int *sd, int proto) { | |||
| 248 | break; | 249 | break; |
| 249 | } | 250 | } |
| 250 | } else { | 251 | } else { |
| 251 | if (is_socket) | 252 | if (is_socket) { |
| 252 | printf("connect to file socket %s: %s\n", host_name, strerror(errno)); | 253 | // printf("connect to file socket %s: %s\n", host_name, strerror(errno)); |
| 253 | else | 254 | } else { |
| 254 | printf("connect to address %s and port %d: %s\n", host_name, port, strerror(errno)); | 255 | // printf("connect to address %s and port %d: %s\n", host_name, port, strerror(errno)); |
| 256 | } | ||
| 255 | return STATE_CRITICAL; | 257 | return STATE_CRITICAL; |
| 256 | } | 258 | } |
| 257 | } | 259 | } |
