summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 8125ee8..99833f6 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -117,7 +117,7 @@ typedef enum curlhelp_ssl_library {
117 117
118enum { 118enum {
119 REGS = 2, 119 REGS = 2,
120 MAX_RE_SIZE = 256 120 MAX_RE_SIZE = 1024
121}; 121};
122#include "regex.h" 122#include "regex.h"
123regex_t preg; 123regex_t preg;
@@ -145,6 +145,7 @@ thresholds *thlds;
145char user_agent[DEFAULT_BUFFER_SIZE]; 145char user_agent[DEFAULT_BUFFER_SIZE];
146int verbose = 0; 146int verbose = 0;
147int show_extended_perfdata = FALSE; 147int show_extended_perfdata = FALSE;
148int show_body = FALSE;
148int min_page_len = 0; 149int min_page_len = 0;
149int max_page_len = 0; 150int max_page_len = 0;
150int redir_depth = 0; 151int 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>");
@@ -1852,10 +1863,16 @@ print_usage (void)
1852 printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport|curl>]\n"); 1863 printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport|curl>]\n");
1853 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); 1864 printf (" [-e <expect>] [-d string] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
1854 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); 1865 printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
1855 printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); 1866 printf (" [-A string] [-k string] [-S <version>] [--sni]\n");
1856 printf (" [-T <content-type>] [-j method]\n"); 1867 printf (" [-T <content-type>] [-j method]\n");
1857 printf (" [--http-version=<version>]\n"); 1868 printf (" [--http-version=<version>]\n");
1869 printf (" %s -H <vhost> | -I <IP-address> -C <warn_age>[,<crit_age>]\n",progname);
1870 printf (" [-p <port>] [-t <timeout>] [-4|-6] [--sni]\n");
1858 printf ("\n"); 1871 printf ("\n");
1872#ifdef LIBCURL_FEATURE_SSL
1873 printf ("%s\n", _("In the first form, make an HTTP request."));
1874 printf ("%s\n\n", _("In the second form, connect to the server and check the TLS certificate."));
1875#endif
1859 printf ("%s\n", _("WARNING: check_curl is experimental. Please use")); 1876 printf ("%s\n", _("WARNING: check_curl is experimental. Please use"));
1860 printf ("%s\n\n", _("check_http if you need a stable version.")); 1877 printf ("%s\n\n", _("check_http if you need a stable version."));
1861} 1878}