summaryrefslogtreecommitdiffstats
path: root/web/attachments/34095-check_http.c.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/34095-check_http.c.patch')
-rw-r--r--web/attachments/34095-check_http.c.patch140
1 files changed, 140 insertions, 0 deletions
diff --git a/web/attachments/34095-check_http.c.patch b/web/attachments/34095-check_http.c.patch
new file mode 100644
index 0000000..0bf48b6
--- /dev/null
+++ b/web/attachments/34095-check_http.c.patch
@@ -0,0 +1,140 @@
1--- plutins/check_http.c 2002-10-28 18:02:11.000000000 +0100
2+++ plugins/check_http.c 2002-10-28 19:42:30.000000000 +0100
3@@ -44,7 +44,7 @@
4 \(-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
5 [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
6 [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
7- [-s string] [-r <regex> | -R <case-insensitive regex>]\n\
8+ [-s string] [-r <regex> | -R <case-insensitive regex>] [-x]\n\
9 [-P string]"
10
11 #define LONGOPTIONS "\
12@@ -71,6 +71,8 @@
13 Seconds before connection times out (default: %d)\n\
14 -a, --authorization=AUTH_PAIR\n\
15 Username:password on sites with basic authentication\n\
16+ -x, --reverse\n\
17+ Reverse the result of -r|-R|-s (like grep -v)\n\
18 -L, --link=URL\n\
19 Wrap output in HTML link (obsoleted by urlize)\n\
20 -f, --onredirect=<ok|warning|critical|follow>\n\
21@@ -190,6 +192,7 @@
22 int server_expect_yn = 0;
23 char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
24 char string_expect[MAX_INPUT_BUFFER] = "";
25+int found_reverse = FALSE; /* grep -v */
26 double warning_time = 0;
27 int check_warning_time = FALSE;
28 double critical_time = 0;
29@@ -287,6 +290,7 @@
30 {"regex", required_argument, 0, 'r'},
31 {"ereg", required_argument, 0, 'r'},
32 {"eregi", required_argument, 0, 'R'},
33+ {"reverse", no_argument, 0, 'x'},
34 {"onredirect", required_argument, 0, 'f'},
35 {"certificate", required_argument, 0, 'C'},
36 {0, 0, 0, 0}
37@@ -309,7 +313,7 @@
38 strcpy (argv[c], "-n");
39 }
40
41-#define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nLS"
42+#define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nLSx"
43
44 while (1) {
45 #ifdef HAVE_GETOPT_H
46@@ -442,6 +446,9 @@
47 usage ("check_http: call for regex which was not a compiled option\n");
48 #endif
49 break;
50+ case 'x': /* grep -v */
51+ found_reverse = TRUE;
52+ break;
53 case 'v': /* verbose */
54 verbose = TRUE;
55 break;
56@@ -849,31 +856,69 @@
57
58 if (strlen (string_expect)) {
59 if (strstr (page, string_expect)) {
60- printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n",
61- status_line, elapsed_time,
62- timestamp, (display_html ? "</A>" : ""), elapsed_time);
63- exit (STATE_OK);
64+ if (found_reverse) { /* grep -v */
65+ printf ("HTTP CRITICAL: string found%s|time=%7.3f\n",
66+ (display_html ? "</A>" : ""),
67+ elapsed_time);
68+ exit (STATE_CRITICAL) ;
69+ } else {
70+ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n",
71+ status_line, elapsed_time,
72+ timestamp,
73+ (display_html ? "</A>" : ""),
74+ elapsed_time);
75+ exit (STATE_OK);
76+ }
77 }
78- else {
79- printf ("HTTP CRITICAL: string not found%s|time=%7.3f\n",
80- (display_html ? "</A>" : ""), elapsed_time);
81- exit (STATE_CRITICAL);
82+ else { /* not found */
83+ if (found_reverse) { /* grep -v */
84+ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n",
85+ status_line, elapsed_time,
86+ timestamp,
87+ (display_html ? "</A>" : ""),
88+ elapsed_time);
89+ exit (STATE_OK) ;
90+ } else {
91+ printf ("HTTP CRITICAL: string not found%s|time=%7.3f\n",
92+ (display_html ? "</A>" : ""), elapsed_time);
93+ exit (STATE_CRITICAL);
94+ }
95 }
96 }
97 #ifdef HAVE_REGEX_H
98 if (strlen (regexp)) {
99 errcode = regexec (&preg, page, REGS, pmatch, 0);
100 if (errcode == 0) {
101- printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n",
102- status_line, elapsed_time,
103- timestamp, (display_html ? "</A>" : ""), elapsed_time);
104- exit (STATE_OK);
105+ if (found_reverse) { /* grep -v */
106+ printf ("HTTP CRITICAL: pattern found%s|time=%7.3f\n",
107+ (display_html ? "</A>" : ""),
108+ elapsed_time);
109+ exit (STATE_CRITICAL);
110+ } else {
111+ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n",
112+ status_line, elapsed_time,
113+ timestamp,
114+ (display_html ? "</A>" : ""),
115+ elapsed_time);
116+ exit (STATE_OK);
117+ }
118 }
119 else {
120 if (errcode == REG_NOMATCH) {
121- printf ("HTTP CRITICAL: pattern not found%s|time=%7.3f\n",
122- (display_html ? "</A>" : ""), elapsed_time);
123- exit (STATE_CRITICAL);
124+ if (found_reverse) { /* grep -v */
125+ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n",
126+ status_line, elapsed_time,
127+ timestamp,
128+ (display_html ? "</A>" : ""),
129+ elapsed_time);
130+ exit (STATE_OK);
131+
132+ } else {
133+ printf ("HTTP CRITICAL: pattern not found%s|time=%7.3f\n",
134+ (display_html ? "</A>" : ""),
135+ elapsed_time);
136+ exit (STATE_CRITICAL);
137+ }
138 }
139 else {
140 regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);