summaryrefslogtreecommitdiffstats
path: root/web/attachments/41493-http.patch
blob: 8492cb21fa051870b04200412afbf425d4d4f705 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.15
diff -u -p -r1.15 check_http.c
--- check_http.c	16 Jan 2003 06:29:02 -0000	1.15
+++ check_http.c	22 Jan 2003 17:53:43 -0000
@@ -45,7 +45,7 @@ certificate expiration times.\n"
             [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
             [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
             [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\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=<ok|warning|critical|follow>\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\
@@ -212,6 +214,7 @@ int onredirect = STATE_OK;
 int use_ssl = FALSE;
 int verbose = FALSE;
 int sd;
+int min_page_len = 0;
 /*@null@*/ char *http_method = NULL;
 /*@null@*/ char *http_post_data = NULL;
 char buffer[MAX_INPUT_BUFFER];
@@ -301,6 +304,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
@@ -321,7 +325,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
@@ -459,6 +463,9 @@ process_arguments (int argc, char **argv
 		case 'v': /* verbose */
 			verbose = TRUE;
 			break;
+		case 'm': /* min_page_length */
+			min_page_len = atoi (optarg);
+			break;
 		}
 	}
 
@@ -548,6 +555,7 @@ check_http (void)
 	char *x = NULL;
 	char *orig_url = NULL;
 	double elapsed_time;
+	int page_len = 0;
 
 	/* try to connect to the host at the given port number */
 #ifdef HAVE_SSL
@@ -895,6 +903,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 ? "</A>" : ""), 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,