diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2003-03-05 00:17:15 (GMT) |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2003-03-05 00:17:15 (GMT) |
commit | cbd684fa0ba4447dcdc3b6d5f9699aca7b5c9047 (patch) | |
tree | 0b8fbc27dd9bfee61e7bc1b3f72ad0ef6be7afc4 /plugins/check_http.c | |
parent | d714b3811dae812838c01b9b0bb1d766a62dcc2f (diff) | |
download | monitoring-plugins-cbd684fa0ba4447dcdc3b6d5f9699aca7b5c9047.tar.gz |
check_http min size option (680467 - Dave Viner)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@365 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 856acde..cf86d46 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -45,7 +45,7 @@ certificate expiration times.\n" | |||
45 | [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\ | 45 | [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\ |
46 | [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\ | 46 | [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\ |
47 | [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\ | 47 | [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\ |
48 | [-P string]" | 48 | [-P string] [-m min_pg_size]" |
49 | 49 | ||
50 | #define LONGOPTIONS "\ | 50 | #define LONGOPTIONS "\ |
51 | -H, --hostname=ADDRESS\n\ | 51 | -H, --hostname=ADDRESS\n\ |
@@ -75,6 +75,8 @@ certificate expiration times.\n" | |||
75 | Wrap output in HTML link (obsoleted by urlize)\n\ | 75 | Wrap output in HTML link (obsoleted by urlize)\n\ |
76 | -f, --onredirect=<ok|warning|critical|follow>\n\ | 76 | -f, --onredirect=<ok|warning|critical|follow>\n\ |
77 | How to handle redirected pages\n%s%s\ | 77 | How to handle redirected pages\n%s%s\ |
78 | -m, --min=INTEGER\n\ | ||
79 | Minimum page size required (bytes)\n\ | ||
78 | -v, --verbose\n\ | 80 | -v, --verbose\n\ |
79 | Show details for command-line debugging (do not use with nagios server)\n\ | 81 | Show details for command-line debugging (do not use with nagios server)\n\ |
80 | -h, --help\n\ | 82 | -h, --help\n\ |
@@ -218,6 +220,7 @@ int onredirect = STATE_OK; | |||
218 | int use_ssl = FALSE; | 220 | int use_ssl = FALSE; |
219 | int verbose = FALSE; | 221 | int verbose = FALSE; |
220 | int sd; | 222 | int sd; |
223 | int min_page_len = 0; | ||
221 | char *http_method = "GET"; | 224 | char *http_method = "GET"; |
222 | char *http_post_data = ""; | 225 | char *http_post_data = ""; |
223 | char buffer[MAX_INPUT_BUFFER]; | 226 | char buffer[MAX_INPUT_BUFFER]; |
@@ -311,6 +314,7 @@ process_arguments (int argc, char **argv) | |||
311 | {"linespan", no_argument, 0, 'l'}, | 314 | {"linespan", no_argument, 0, 'l'}, |
312 | {"onredirect", required_argument, 0, 'f'}, | 315 | {"onredirect", required_argument, 0, 'f'}, |
313 | {"certificate", required_argument, 0, 'C'}, | 316 | {"certificate", required_argument, 0, 'C'}, |
317 | {"min", required_argument, 0, 'm'}, | ||
314 | {0, 0, 0, 0} | 318 | {0, 0, 0, 0} |
315 | }; | 319 | }; |
316 | #endif | 320 | #endif |
@@ -331,7 +335,7 @@ process_arguments (int argc, char **argv) | |||
331 | strcpy (argv[c], "-n"); | 335 | strcpy (argv[c], "-n"); |
332 | } | 336 | } |
333 | 337 | ||
334 | #define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLS" | 338 | #define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:" |
335 | 339 | ||
336 | while (1) { | 340 | while (1) { |
337 | #ifdef HAVE_GETOPT_H | 341 | #ifdef HAVE_GETOPT_H |
@@ -469,6 +473,9 @@ process_arguments (int argc, char **argv) | |||
469 | case 'v': /* verbose */ | 473 | case 'v': /* verbose */ |
470 | verbose = TRUE; | 474 | verbose = TRUE; |
471 | break; | 475 | break; |
476 | case 'm': /* min_page_length */ | ||
477 | min_page_len = atoi (optarg); | ||
478 | break; | ||
472 | } | 479 | } |
473 | } | 480 | } |
474 | 481 | ||
@@ -550,6 +557,7 @@ check_http (void) | |||
550 | char *x = NULL; | 557 | char *x = NULL; |
551 | char *orig_url = NULL; | 558 | char *orig_url = NULL; |
552 | double elapsed_time; | 559 | double elapsed_time; |
560 | int page_len = 0; | ||
553 | #ifdef HAVE_SSL | 561 | #ifdef HAVE_SSL |
554 | int sslerr; | 562 | int sslerr; |
555 | #endif | 563 | #endif |
@@ -855,6 +863,13 @@ check_http (void) | |||
855 | } | 863 | } |
856 | #endif | 864 | #endif |
857 | 865 | ||
866 | /* make sure the page is of an appropriate size */ | ||
867 | page_len = strlen (page); | ||
868 | if ((min_page_len > 0) && (page_len < min_page_len)) { | ||
869 | printf ("HTTP WARNING: page size too small%s|size=%i\n", | ||
870 | (display_html ? "</A>" : ""), page_len ); | ||
871 | exit (STATE_WARNING); | ||
872 | } | ||
858 | /* We only get here if all tests have been passed */ | 873 | /* We only get here if all tests have been passed */ |
859 | asprintf (&msg, "HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", | 874 | asprintf (&msg, "HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", |
860 | status_line, (float)elapsed_time, | 875 | status_line, (float)elapsed_time, |