From cbd684fa0ba4447dcdc3b6d5f9699aca7b5c9047 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Wed, 5 Mar 2003 00:17:15 +0000 Subject: 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 --- plugins/check_http.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/check_http.c b/plugins/check_http.c index 856acdea..cf86d469 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -45,7 +45,7 @@ certificate expiration times.\n" [-w ] [-c ] [-t ] [-L]\n\ [-a auth] [-f ] [-e ]\n\ [-s string] [-l] [-r | -R ]\n\ - [-P string]" + [-P string] [-m min_pg_size]" #define LONGOPTIONS "\ -H, --hostname=ADDRESS\n\ @@ -75,6 +75,8 @@ certificate expiration times.\n" Wrap output in HTML link (obsoleted by urlize)\n\ -f, --onredirect=\n\ How to handle redirected pages\n%s%s\ +-m, --min=INTEGER\n\ + Minimum page size required (bytes)\n\ -v, --verbose\n\ Show details for command-line debugging (do not use with nagios server)\n\ -h, --help\n\ @@ -218,6 +220,7 @@ int onredirect = STATE_OK; int use_ssl = FALSE; int verbose = FALSE; int sd; +int min_page_len = 0; char *http_method = "GET"; char *http_post_data = ""; char buffer[MAX_INPUT_BUFFER]; @@ -311,6 +314,7 @@ process_arguments (int argc, char **argv) {"linespan", no_argument, 0, 'l'}, {"onredirect", required_argument, 0, 'f'}, {"certificate", required_argument, 0, 'C'}, + {"min", required_argument, 0, 'm'}, {0, 0, 0, 0} }; #endif @@ -331,7 +335,7 @@ process_arguments (int argc, char **argv) strcpy (argv[c], "-n"); } -#define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLS" +#define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLSm:" while (1) { #ifdef HAVE_GETOPT_H @@ -469,6 +473,9 @@ process_arguments (int argc, char **argv) case 'v': /* verbose */ verbose = TRUE; break; + case 'm': /* min_page_length */ + min_page_len = atoi (optarg); + break; } } @@ -550,6 +557,7 @@ check_http (void) char *x = NULL; char *orig_url = NULL; double elapsed_time; + int page_len = 0; #ifdef HAVE_SSL int sslerr; #endif @@ -855,6 +863,13 @@ check_http (void) } #endif + /* make sure the page is of an appropriate size */ + page_len = strlen (page); + if ((min_page_len > 0) && (page_len < min_page_len)) { + printf ("HTTP WARNING: page size too small%s|size=%i\n", + (display_html ? "" : ""), page_len ); + exit (STATE_WARNING); + } /* We only get here if all tests have been passed */ asprintf (&msg, "HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", status_line, (float)elapsed_time, -- cgit v1.2.3-74-g34f1