diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | plugins/check_http.c | 7 | ||||
-rwxr-xr-x | plugins/tests/check_http.t | 10 |
3 files changed, 16 insertions, 2 deletions
@@ -7,6 +7,7 @@ This file documents the major additions and syntax changes between releases. | |||
7 | New check_radius -N option which allows for specifying the value of the NAS-IP-Address attribute | 7 | New check_radius -N option which allows for specifying the value of the NAS-IP-Address attribute |
8 | New check_snmp --rate option to store differences between invocations. Saves state in PREFIX/var/{plugin} | 8 | New check_snmp --rate option to store differences between invocations. Saves state in PREFIX/var/{plugin} |
9 | check_snmp -l label option now also changes the perfdata label. See WARNINGS | 9 | check_snmp -l label option now also changes the perfdata label. See WARNINGS |
10 | check_http now displays the missing search string and the URL in the output when failed (Duncan Ferguson - #2999924) | ||
10 | Updated Nagios::Plugin perl module | 11 | Updated Nagios::Plugin perl module |
11 | Updated gnulib to June 2010 | 12 | Updated gnulib to June 2010 |
12 | FIXES | 13 | FIXES |
diff --git a/plugins/check_http.c b/plugins/check_http.c index 7f773c8..f08ad17 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -100,6 +100,7 @@ int server_url_length; | |||
100 | int server_expect_yn = 0; | 100 | int server_expect_yn = 0; |
101 | char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; | 101 | char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; |
102 | char string_expect[MAX_INPUT_BUFFER] = ""; | 102 | char string_expect[MAX_INPUT_BUFFER] = ""; |
103 | char output_string_search[30] = ""; | ||
103 | double warning_time = 0; | 104 | double warning_time = 0; |
104 | int check_warning_time = FALSE; | 105 | int check_warning_time = FALSE; |
105 | double critical_time = 0; | 106 | double critical_time = 0; |
@@ -1037,7 +1038,11 @@ check_http (void) | |||
1037 | 1038 | ||
1038 | if (strlen (string_expect)) { | 1039 | if (strlen (string_expect)) { |
1039 | if (!strstr (page, string_expect)) { | 1040 | if (!strstr (page, string_expect)) { |
1040 | asprintf (&msg, _("%sstring not found, "), msg); | 1041 | strncpy(&output_string_search[0],string_expect,sizeof(output_string_search)); |
1042 | if(output_string_search[sizeof(output_string_search)-1]!='\0') { | ||
1043 | bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); | ||
1044 | } | ||
1045 | asprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); | ||
1041 | result = STATE_CRITICAL; | 1046 | result = STATE_CRITICAL; |
1042 | } | 1047 | } |
1043 | } | 1048 | } |
diff --git a/plugins/tests/check_http.t b/plugins/tests/check_http.t index 88b77d3..f03933b 100755 --- a/plugins/tests/check_http.t +++ b/plugins/tests/check_http.t | |||
@@ -157,7 +157,7 @@ if ($ARGV[0] && $ARGV[0] eq "-d") { | |||
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | my $common_tests = 62; | 160 | my $common_tests = 66; |
161 | my $ssl_only_tests = 6; | 161 | my $ssl_only_tests = 6; |
162 | if (-x "./check_http") { | 162 | if (-x "./check_http") { |
163 | plan tests => $common_tests * 2 + $ssl_only_tests; | 163 | plan tests => $common_tests * 2 + $ssl_only_tests; |
@@ -205,6 +205,14 @@ sub run_common_tests { | |||
205 | is( $result->return_code, 0, "/file/root search for string"); | 205 | is( $result->return_code, 0, "/file/root search for string"); |
206 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" ); | 206 | like( $result->output, '/^HTTP OK: HTTP/1.1 200 OK - 274 bytes in [\d\.]+ second/', "Output correct" ); |
207 | 207 | ||
208 | $result = NPTest->testCmd( "$command -u /file/root -s NonRoot" ); | ||
209 | is( $result->return_code, 2, "Missing string check"); | ||
210 | like( $result->output, qr%^HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRoot' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location"); | ||
211 | |||
212 | $result = NPTest->testCmd( "$command -u /file/root -s NonRootWithOver30charsAndMoreFunThanAWetFish" ); | ||
213 | is( $result->return_code, 2, "Missing string check"); | ||
214 | like( $result->output, qr%HTTP CRITICAL: HTTP/1\.1 200 OK - string 'NonRootWithOver30charsAndM...' not found on 'https?://127\.0\.0\.1:\d+/file/root'%, "Shows search string and location"); | ||
215 | |||
208 | 216 | ||
209 | my $cmd; | 217 | my $cmd; |
210 | $cmd = "$command -u /slow"; | 218 | $cmd = "$command -u /slow"; |