diff options
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 86a36c20..de59a068 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -120,12 +120,14 @@ int use_ssl = FALSE; | |||
120 | int use_sni = FALSE; | 120 | int use_sni = FALSE; |
121 | int verbose = FALSE; | 121 | int verbose = FALSE; |
122 | int show_extended_perfdata = FALSE; | 122 | int show_extended_perfdata = FALSE; |
123 | int show_body = FALSE; | ||
123 | int sd; | 124 | int sd; |
124 | int min_page_len = 0; | 125 | int min_page_len = 0; |
125 | int max_page_len = 0; | 126 | int max_page_len = 0; |
126 | int redir_depth = 0; | 127 | int redir_depth = 0; |
127 | int max_depth = 15; | 128 | int max_depth = 15; |
128 | char *http_method; | 129 | char *http_method; |
130 | char *http_method_proxy; | ||
129 | char *http_post_data; | 131 | char *http_post_data; |
130 | char *http_content_type; | 132 | char *http_content_type; |
131 | char buffer[MAX_INPUT_BUFFER]; | 133 | char buffer[MAX_INPUT_BUFFER]; |
@@ -239,6 +241,7 @@ process_arguments (int argc, char **argv) | |||
239 | {"use-ipv4", no_argument, 0, '4'}, | 241 | {"use-ipv4", no_argument, 0, '4'}, |
240 | {"use-ipv6", no_argument, 0, '6'}, | 242 | {"use-ipv6", no_argument, 0, '6'}, |
241 | {"extended-perfdata", no_argument, 0, 'E'}, | 243 | {"extended-perfdata", no_argument, 0, 'E'}, |
244 | {"show-body", no_argument, 0, 'B'}, | ||
242 | {0, 0, 0, 0} | 245 | {0, 0, 0, 0} |
243 | }; | 246 | }; |
244 | 247 | ||
@@ -259,7 +262,7 @@ process_arguments (int argc, char **argv) | |||
259 | } | 262 | } |
260 | 263 | ||
261 | while (1) { | 264 | while (1) { |
262 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option); | 265 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NEB", longopts, &option); |
263 | if (c == -1 || c == EOF) | 266 | if (c == -1 || c == EOF) |
264 | break; | 267 | break; |
265 | 268 | ||
@@ -446,6 +449,12 @@ process_arguments (int argc, char **argv) | |||
446 | if (http_method) | 449 | if (http_method) |
447 | free(http_method); | 450 | free(http_method); |
448 | http_method = strdup (optarg); | 451 | http_method = strdup (optarg); |
452 | char *tmp; | ||
453 | if ((tmp = strstr(http_method, ":")) > 0) { | ||
454 | tmp[0] = '\0'; | ||
455 | http_method = http_method; | ||
456 | http_method_proxy = ++tmp; | ||
457 | } | ||
449 | break; | 458 | break; |
450 | case 'd': /* string or substring */ | 459 | case 'd': /* string or substring */ |
451 | strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1); | 460 | strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1); |
@@ -540,6 +549,9 @@ process_arguments (int argc, char **argv) | |||
540 | case 'E': /* show extended perfdata */ | 549 | case 'E': /* show extended perfdata */ |
541 | show_extended_perfdata = TRUE; | 550 | show_extended_perfdata = TRUE; |
542 | break; | 551 | break; |
552 | case 'B': /* print body content after status line */ | ||
553 | show_body = TRUE; | ||
554 | break; | ||
543 | } | 555 | } |
544 | } | 556 | } |
545 | 557 | ||
@@ -566,6 +578,9 @@ process_arguments (int argc, char **argv) | |||
566 | if (http_method == NULL) | 578 | if (http_method == NULL) |
567 | http_method = strdup ("GET"); | 579 | http_method = strdup ("GET"); |
568 | 580 | ||
581 | if (http_method_proxy == NULL) | ||
582 | http_method_proxy = strdup ("GET"); | ||
583 | |||
569 | if (client_cert && !client_privkey) | 584 | if (client_cert && !client_privkey) |
570 | usage4 (_("If you use a client certificate you must also specify a private key file")); | 585 | usage4 (_("If you use a client certificate you must also specify a private key file")); |
571 | 586 | ||
@@ -950,7 +965,7 @@ check_http (void) | |||
950 | 965 | ||
951 | if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 | 966 | if ( server_address != NULL && strcmp(http_method, "CONNECT") == 0 |
952 | && host_name != NULL && use_ssl == TRUE) | 967 | && host_name != NULL && use_ssl == TRUE) |
953 | asprintf (&buf, "%s %s %s\r\n%s\r\n", "GET", server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | 968 | asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method_proxy, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); |
954 | else | 969 | else |
955 | asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | 970 | asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); |
956 | 971 | ||
@@ -1140,6 +1155,8 @@ check_http (void) | |||
1140 | xasprintf (&msg, | 1155 | xasprintf (&msg, |
1141 | _("Invalid HTTP response received from host on port %d: %s\n"), | 1156 | _("Invalid HTTP response received from host on port %d: %s\n"), |
1142 | server_port, status_line); | 1157 | server_port, status_line); |
1158 | if (show_body) | ||
1159 | xasprintf (&msg, _("%s\n%s"), msg, page); | ||
1143 | die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); | 1160 | die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); |
1144 | } | 1161 | } |
1145 | 1162 | ||
@@ -1290,6 +1307,9 @@ check_http (void) | |||
1290 | perfd_time (elapsed_time), | 1307 | perfd_time (elapsed_time), |
1291 | perfd_size (page_len)); | 1308 | perfd_size (page_len)); |
1292 | 1309 | ||
1310 | if (show_body) | ||
1311 | xasprintf (&msg, _("%s\n%s"), msg, page); | ||
1312 | |||
1293 | result = max_state_alt(get_status(elapsed_time, thlds), result); | 1313 | result = max_state_alt(get_status(elapsed_time, thlds), result); |
1294 | 1314 | ||
1295 | die (result, "HTTP %s: %s\n", state_text(result), msg); | 1315 | die (result, "HTTP %s: %s\n", state_text(result), msg); |
@@ -1581,7 +1601,7 @@ print_help (void) | |||
1581 | printf (" %s\n", _("URL to GET or POST (default: /)")); | 1601 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
1582 | printf (" %s\n", "-P, --post=STRING"); | 1602 | printf (" %s\n", "-P, --post=STRING"); |
1583 | printf (" %s\n", _("URL encoded http POST data")); | 1603 | printf (" %s\n", _("URL encoded http POST data")); |
1584 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)"); | 1604 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT, CONNECT:POST)"); |
1585 | printf (" %s\n", _("Set HTTP method.")); | 1605 | printf (" %s\n", _("Set HTTP method.")); |
1586 | printf (" %s\n", "-N, --no-body"); | 1606 | printf (" %s\n", "-N, --no-body"); |
1587 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); | 1607 | printf (" %s\n", _("Don't wait for document body: stop reading after headers.")); |
@@ -1611,6 +1631,8 @@ print_help (void) | |||
1611 | printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); | 1631 | printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); |
1612 | printf (" %s\n", "-E, --extended-perfdata"); | 1632 | printf (" %s\n", "-E, --extended-perfdata"); |
1613 | printf (" %s\n", _("Print additional performance data")); | 1633 | printf (" %s\n", _("Print additional performance data")); |
1634 | printf (" %s\n", "-B, --show-body"); | ||
1635 | printf (" %s\n", _("Print body content below status line")); | ||
1614 | printf (" %s\n", "-L, --link"); | 1636 | printf (" %s\n", "-L, --link"); |
1615 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); | 1637 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); |
1616 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); | 1638 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); |
@@ -1668,7 +1690,8 @@ print_help (void) | |||
1668 | printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>")); | 1690 | printf (" %s\n", _("all these options are needed: -I <proxy> -p <proxy-port> -u <check-url> -S(sl) -j CONNECT -H <webserver>")); |
1669 | printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); | 1691 | printf (" %s\n", _("a STATE_OK will be returned. When the server returns its content but exceeds")); |
1670 | printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); | 1692 | printf (" %s\n", _("the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,")); |
1671 | printf (" %s\n", _("a STATE_CRITICAL will be returned.")); | 1693 | printf (" %s\n", _("a STATE_CRITICAL will be returned. By adding a colon to the method you can set the method used")); |
1694 | printf (" %s\n", _("inside the proxied connection: -j CONNECT:POST")); | ||
1672 | 1695 | ||
1673 | #endif | 1696 | #endif |
1674 | 1697 | ||