diff options
-rw-r--r-- | plugins/check_curl.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 8fc97f4..99833f6 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -145,6 +145,7 @@ thresholds *thlds; | |||
145 | char user_agent[DEFAULT_BUFFER_SIZE]; | 145 | char user_agent[DEFAULT_BUFFER_SIZE]; |
146 | int verbose = 0; | 146 | int verbose = 0; |
147 | int show_extended_perfdata = FALSE; | 147 | int show_extended_perfdata = FALSE; |
148 | int show_body = FALSE; | ||
148 | int min_page_len = 0; | 149 | int min_page_len = 0; |
149 | int max_page_len = 0; | 150 | int max_page_len = 0; |
150 | int redir_depth = 0; | 151 | int redir_depth = 0; |
@@ -792,7 +793,9 @@ GOT_FIRST_CERT: | |||
792 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host: %s\n"), status_line.first_line); | 793 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host: %s\n"), status_line.first_line); |
793 | else | 794 | else |
794 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: %s\n"), server_port, status_line.first_line); | 795 | snprintf(msg, DEFAULT_BUFFER_SIZE, _("Invalid HTTP response received from host on port %d: %s\n"), server_port, status_line.first_line); |
795 | die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); | 796 | die (STATE_CRITICAL, "HTTP CRITICAL - %s%s%s", msg, |
797 | show_body ? "\n" : "", | ||
798 | show_body ? body_buf.buf : ""); | ||
796 | } | 799 | } |
797 | 800 | ||
798 | if( server_expect_yn ) { | 801 | if( server_expect_yn ) { |
@@ -921,13 +924,15 @@ GOT_FIRST_CERT: | |||
921 | msg[strlen(msg)-3] = '\0'; | 924 | msg[strlen(msg)-3] = '\0'; |
922 | 925 | ||
923 | /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ | 926 | /* TODO: separate _() msg and status code: die (result, "HTTP %s: %s\n", state_text(result), msg); */ |
924 | die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n", | 927 | die (result, "HTTP %s: %s %d %s%s%s - %d bytes in %.3f second response time %s|%s\n%s%s", |
925 | state_text(result), string_statuscode (status_line.http_major, status_line.http_minor), | 928 | state_text(result), string_statuscode (status_line.http_major, status_line.http_minor), |
926 | status_line.http_code, status_line.msg, | 929 | status_line.http_code, status_line.msg, |
927 | strlen(msg) > 0 ? " - " : "", | 930 | strlen(msg) > 0 ? " - " : "", |
928 | msg, page_len, total_time, | 931 | msg, page_len, total_time, |
929 | (display_html ? "</A>" : ""), | 932 | (display_html ? "</A>" : ""), |
930 | perfstring); | 933 | perfstring, |
934 | (show_body ? body_buf.buf : ""), | ||
935 | (show_body ? "\n" : "") ); | ||
931 | 936 | ||
932 | /* proper cleanup after die? */ | 937 | /* proper cleanup after die? */ |
933 | curlhelp_free_statusline(&status_line); | 938 | curlhelp_free_statusline(&status_line); |
@@ -1173,6 +1178,7 @@ process_arguments (int argc, char **argv) | |||
1173 | {"use-ipv4", no_argument, 0, '4'}, | 1178 | {"use-ipv4", no_argument, 0, '4'}, |
1174 | {"use-ipv6", no_argument, 0, '6'}, | 1179 | {"use-ipv6", no_argument, 0, '6'}, |
1175 | {"extended-perfdata", no_argument, 0, 'E'}, | 1180 | {"extended-perfdata", no_argument, 0, 'E'}, |
1181 | {"show-body", no_argument, 0, 'B'}, | ||
1176 | {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, | 1182 | {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, |
1177 | {0, 0, 0, 0} | 1183 | {0, 0, 0, 0} |
1178 | }; | 1184 | }; |
@@ -1197,7 +1203,7 @@ process_arguments (int argc, char **argv) | |||
1197 | server_url = strdup(DEFAULT_SERVER_URL); | 1203 | server_url = strdup(DEFAULT_SERVER_URL); |
1198 | 1204 | ||
1199 | while (1) { | 1205 | while (1) { |
1200 | 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:DnlLS::m:M:NE", longopts, &option); | 1206 | 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:DnlLS::m:M:NEB", longopts, &option); |
1201 | if (c == -1 || c == EOF || c == 1) | 1207 | if (c == -1 || c == EOF || c == 1) |
1202 | break; | 1208 | break; |
1203 | 1209 | ||
@@ -1545,6 +1551,9 @@ process_arguments (int argc, char **argv) | |||
1545 | case 'E': /* show extended perfdata */ | 1551 | case 'E': /* show extended perfdata */ |
1546 | show_extended_perfdata = TRUE; | 1552 | show_extended_perfdata = TRUE; |
1547 | break; | 1553 | break; |
1554 | case 'B': /* print body content after status line */ | ||
1555 | show_body = TRUE; | ||
1556 | break; | ||
1548 | case HTTP_VERSION_OPTION: | 1557 | case HTTP_VERSION_OPTION: |
1549 | curl_http_version = CURL_HTTP_VERSION_NONE; | 1558 | curl_http_version = CURL_HTTP_VERSION_NONE; |
1550 | if (strcmp (optarg, "1.0") == 0) { | 1559 | if (strcmp (optarg, "1.0") == 0) { |
@@ -1757,6 +1766,8 @@ print_help (void) | |||
1757 | printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); | 1766 | printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); |
1758 | printf (" %s\n", "-E, --extended-perfdata"); | 1767 | printf (" %s\n", "-E, --extended-perfdata"); |
1759 | printf (" %s\n", _("Print additional performance data")); | 1768 | printf (" %s\n", _("Print additional performance data")); |
1769 | printf (" %s\n", "-B, --show-body"); | ||
1770 | printf (" %s\n", _("Print body content below status line")); | ||
1760 | printf (" %s\n", "-L, --link"); | 1771 | printf (" %s\n", "-L, --link"); |
1761 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); | 1772 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); |
1762 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport|curl>"); | 1773 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport|curl>"); |