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
|
--- check_http.c.old 2010-07-27 12:47:16.000000000 -0700
+++ check_http.c 2012-01-03 16:43:56.000000000 -0800
@@ -99,7 +99,9 @@
int server_url_length;
int server_expect_yn = 0;
char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
+char header_expect[MAX_INPUT_BUFFER] = "";
char string_expect[MAX_INPUT_BUFFER] = "";
+char output_header_search[30] = "";
char output_string_search[30] = "";
double warning_time = 0;
int check_warning_time = FALSE;
@@ -198,6 +200,7 @@
{"port", required_argument, 0, 'p'},
{"authorization", required_argument, 0, 'a'},
{"proxy_authorization", required_argument, 0, 'b'},
+ {"return_header", required_argument, 0, 'd'},
{"string", required_argument, 0, 's'},
{"expect", required_argument, 0, 'e'},
{"regex", required_argument, 0, 'r'},
@@ -235,7 +238,7 @@
}
while (1) {
- c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option);
+ 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:nlLSm:M:N", longopts, &option);
if (c == -1 || c == EOF)
break;
@@ -374,6 +377,10 @@
free(http_method);
http_method = strdup (optarg);
break;
+ case 'd': /* string or substring */
+ strncpy (header_expect, optarg, MAX_INPUT_BUFFER - 1);
+ header_expect[MAX_INPUT_BUFFER - 1] = 0;
+ break;
case 's': /* string or substring */
strncpy (string_expect, optarg, MAX_INPUT_BUFFER - 1);
string_expect[MAX_INPUT_BUFFER - 1] = 0;
@@ -1036,6 +1043,18 @@
/* Page and Header content checks go here */
+ if (strlen (header_expect)) {
+ if (!strstr (header, header_expect)) {
+ strncpy(&output_header_search[0],header_expect,sizeof(output_header_search));
+ if(output_header_search[sizeof(output_header_search)-1]!='\0') {
+ bcopy("...",&output_header_search[sizeof(output_header_search)-4],4);
+ }
+ asprintf (&msg, _("%sheader '%s' not found on '%s://%s:%d%s', "), msg, output_header_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url);
+ result = STATE_CRITICAL;
+ }
+ }
+
+
if (strlen (string_expect)) {
if (!strstr (page, string_expect)) {
strncpy(&output_string_search[0],string_expect,sizeof(output_string_search));
@@ -1368,6 +1387,8 @@
printf (" %s\n", "-l, --linespan");
printf (" %s\n", _("Allow regex to span newlines (must precede -r or -R)"));
+ printf (" %s\n", "-d, --header-string=STRING");
+ printf (" %s\n", _("Search header for regex STRING"));
printf (" %s\n", "-r, --regex, --ereg=STRING");
printf (" %s\n", _("Search page for regex STRING"));
printf (" %s\n", "-R, --eregi=STRING");
@@ -1438,7 +1459,7 @@
printf ("%s\n", _("Usage:"));
printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname);
printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]\n");
- printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n");
+ printf (" [-b proxy_auth] [-d string] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n");
printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
printf (" [-A string] [-k string] [-S] [--sni] [-C <age>] [-T <content-type>]\n");
|