summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorBarak Shohat <barak@bazzisoft.com>2021-04-06 13:35:20 (GMT)
committerBarak Shohat <barak@bazzisoft.com>2021-04-07 09:36:55 (GMT)
commit2482950e267a752b37d696c10ea091dc62d6d8a7 (patch)
tree4d83308070e360cad99a21537337a9d8f01ae14e /plugins
parent57b4dc0f2307cd49bedeed01ee56bc6077d428f5 (diff)
downloadmonitoring-plugins-2482950e267a752b37d696c10ea091dc62d6d8a7.tar.gz
Updated check_curl.c to display a specific human-readable error message where possiblerefs/pull/1668/head
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_curl.c6
-rw-r--r--plugins/t/check_curl.t4
2 files changed, 5 insertions, 5 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 8f274c2..8cb2ff4 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -313,8 +313,8 @@ static char *string_statuscode (int major, int minor)
313 /* assuming here HTTP/N with N>=4 */ 313 /* assuming here HTTP/N with N>=4 */
314 snprintf (buf, sizeof (buf), "HTTP/%d", major); 314 snprintf (buf, sizeof (buf), "HTTP/%d", major);
315 break; 315 break;
316 } 316 }
317 317
318 return buf; 318 return buf;
319} 319}
320 320
@@ -662,7 +662,7 @@ check_http (void)
662 /* Curl errors, result in critical Nagios state */ 662 /* Curl errors, result in critical Nagios state */
663 if (res != CURLE_OK) { 663 if (res != CURLE_OK) {
664 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"), 664 snprintf (msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: cURL returned %d - %s"),
665 server_port, res, curl_easy_strerror(res)); 665 server_port, res, errbuf[0] ? errbuf : curl_easy_strerror(res));
666 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg); 666 die (STATE_CRITICAL, "HTTP CRITICAL - %s\n", msg);
667 } 667 }
668 668
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
index 4bff538..cc65f03 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -46,7 +46,7 @@ $res = NPTest->testCmd(
46 ); 46 );
47cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" ); 47cmp_ok( $res->return_code, '==', 2, "Webserver $host_nonresponsive not responding" );
48# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!) 48# was CRITICAL only, but both check_curl and check_http print HTTP CRITICAL (puzzle?!)
49cmp_ok( $res->output, 'eq', "HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Timeout was reached", "Output OK"); 49like( $res->output, "/HTTP CRITICAL - Invalid HTTP response received from host on port 80: cURL returned 28 - Connection timed out after/", "Output OK");
50 50
51$res = NPTest->testCmd( 51$res = NPTest->testCmd(
52 "./$plugin $hostname_invalid -wt 1 -ct 2" 52 "./$plugin $hostname_invalid -wt 1 -ct 2"
@@ -56,7 +56,7 @@ cmp_ok( $res->return_code, '==', 2, "Webserver $hostname_invalid not valid" );
56# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename 56# On Debian, it is Name or service not known, on Darwin, it is No address associated with nodename
57# Is also possible to get a socket timeout if DNS is not responding fast enough 57# Is also possible to get a socket timeout if DNS is not responding fast enough
58# cURL gives us consistent strings from it's own 'lib/strerror.c' 58# cURL gives us consistent strings from it's own 'lib/strerror.c'
59like( $res->output, "/cURL returned 6 - Couldn't resolve host name/", "Output OK"); 59like( $res->output, "/cURL returned 6 - Could not resolve host:/", "Output OK");
60 60
61# host header checks 61# host header checks
62$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http"); 62$res = NPTest->testCmd("./$plugin -v -H $host_tcp_http");