diff options
author | Tobias Wolf <towolf@gmail.com> | 2018-11-09 22:48:56 (GMT) |
---|---|---|
committer | Tobias Wolf <towolf@gmail.com> | 2018-11-09 22:48:56 (GMT) |
commit | 9966ebcd8494083a1b87e7d368bedfffb5e5fe59 (patch) | |
tree | cf800bbf705f439cbb0becf029a949e95b33feb1 | |
parent | 0863a4cb93a069523b7fca8a29e60e27070125e8 (diff) | |
download | monitoring-plugins-9966ebcd8494083a1b87e7d368bedfffb5e5fe59.tar.gz |
Add new flag --show-body/-B to print bodyrefs/pull/1560/head
This should help with figuring out ia problem at a glance when enabled for
healthz endpoints on web APIs, for example.
The content of the body can point to what the problem is and help with
diagnostics.
Fixes #1559
-rw-r--r-- | plugins/check_http.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 1e2a54c..856e1e9 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -120,6 +120,7 @@ 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; |
@@ -240,6 +241,7 @@ process_arguments (int argc, char **argv) | |||
240 | {"use-ipv4", no_argument, 0, '4'}, | 241 | {"use-ipv4", no_argument, 0, '4'}, |
241 | {"use-ipv6", no_argument, 0, '6'}, | 242 | {"use-ipv6", no_argument, 0, '6'}, |
242 | {"extended-perfdata", no_argument, 0, 'E'}, | 243 | {"extended-perfdata", no_argument, 0, 'E'}, |
244 | {"show-body", no_argument, 0, 'B'}, | ||
243 | {0, 0, 0, 0} | 245 | {0, 0, 0, 0} |
244 | }; | 246 | }; |
245 | 247 | ||
@@ -260,7 +262,7 @@ process_arguments (int argc, char **argv) | |||
260 | } | 262 | } |
261 | 263 | ||
262 | while (1) { | 264 | while (1) { |
263 | 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); |
264 | if (c == -1 || c == EOF) | 266 | if (c == -1 || c == EOF) |
265 | break; | 267 | break; |
266 | 268 | ||
@@ -547,6 +549,9 @@ process_arguments (int argc, char **argv) | |||
547 | case 'E': /* show extended perfdata */ | 549 | case 'E': /* show extended perfdata */ |
548 | show_extended_perfdata = TRUE; | 550 | show_extended_perfdata = TRUE; |
549 | break; | 551 | break; |
552 | case 'B': /* print body content after status line */ | ||
553 | show_body = TRUE; | ||
554 | break; | ||
550 | } | 555 | } |
551 | } | 556 | } |
552 | 557 | ||
@@ -1300,6 +1305,9 @@ check_http (void) | |||
1300 | perfd_time (elapsed_time), | 1305 | perfd_time (elapsed_time), |
1301 | perfd_size (page_len)); | 1306 | perfd_size (page_len)); |
1302 | 1307 | ||
1308 | if (show_body) | ||
1309 | xasprintf (&msg, _("%s\n%s"), msg, page); | ||
1310 | |||
1303 | result = max_state_alt(get_status(elapsed_time, thlds), result); | 1311 | result = max_state_alt(get_status(elapsed_time, thlds), result); |
1304 | 1312 | ||
1305 | die (result, "HTTP %s: %s\n", state_text(result), msg); | 1313 | die (result, "HTTP %s: %s\n", state_text(result), msg); |
@@ -1621,6 +1629,8 @@ print_help (void) | |||
1621 | printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); | 1629 | printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers")); |
1622 | printf (" %s\n", "-E, --extended-perfdata"); | 1630 | printf (" %s\n", "-E, --extended-perfdata"); |
1623 | printf (" %s\n", _("Print additional performance data")); | 1631 | printf (" %s\n", _("Print additional performance data")); |
1632 | printf (" %s\n", "-B, --show-body"); | ||
1633 | printf (" %s\n", _("Print body content below status line")); | ||
1624 | printf (" %s\n", "-L, --link"); | 1634 | printf (" %s\n", "-L, --link"); |
1625 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); | 1635 | printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); |
1626 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); | 1636 | printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); |