diff --git a/plugins/check_http.c b/plugins/check_http.c index 7f773c8..d363c17 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -100,6 +100,7 @@ int server_url_length; int server_expect_yn = 0; char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; char string_expect[MAX_INPUT_BUFFER] = ""; +int output_string_match = FALSE; double warning_time = 0; int check_warning_time = FALSE; double critical_time = 0; @@ -198,6 +199,7 @@ process_arguments (int argc, char **argv) {"authorization", required_argument, 0, 'a'}, {"proxy_authorization", required_argument, 0, 'b'}, {"string", required_argument, 0, 's'}, + {"output-string-match", no_argument, 0, 'o'}, {"expect", required_argument, 0, 'e'}, {"regex", required_argument, 0, 'r'}, {"ereg", required_argument, 0, 'r'}, @@ -234,7 +236,7 @@ process_arguments (int argc, char **argv) } while (1) { - c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); + c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:oR:r:u:f:C:nlLSm:M:N", longopts, &option); if (c == -1 || c == EOF) break; @@ -377,6 +379,9 @@ process_arguments (int argc, char **argv) strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1); string_expect[MAX_INPUT_BUFFER - 1] = 0; break; + case 'o': /* output 'string' in STDOUT 'string not found' msg */ + output_string_match = TRUE; + break; case 'e': /* string or substring */ strncpy (server_expect, optarg, MAX_INPUT_BUFFER - 1); server_expect[MAX_INPUT_BUFFER - 1] = 0; @@ -1037,7 +1042,11 @@ check_http (void) if (strlen (string_expect)) { if (!strstr (page, string_expect)) { - asprintf (&msg, _("%sstring not found, "), msg); + if(!output_string_match){ + asprintf (&msg, _("%sstring not found, "), msg); + } else { + asprintf (&msg, _("%sstring '%s' not found, "), msg, string_expect); + } result = STATE_CRITICAL; } } @@ -1346,6 +1355,8 @@ print_help (void) printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); printf (" %s\n", "-s, --string=STRING"); printf (" %s\n", _("String to expect in the content")); + printf (" %s\n", "-o, --output-string-match"); + printf (" %s\n", _("Show given string as 'string xxx not found' message")); printf (" %s\n", "-u, --url=PATH"); printf (" %s\n", _("URL to GET or POST (default: /)")); printf (" %s\n", "-P, --post=STRING");