summaryrefslogtreecommitdiffstats
path: root/web/attachments/289944-check_http.extented_status_codes.diff.3
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/289944-check_http.extented_status_codes.diff.3')
-rw-r--r--web/attachments/289944-check_http.extented_status_codes.diff.382
1 files changed, 82 insertions, 0 deletions
diff --git a/web/attachments/289944-check_http.extented_status_codes.diff.3 b/web/attachments/289944-check_http.extented_status_codes.diff.3
new file mode 100644
index 0000000..141e707
--- /dev/null
+++ b/web/attachments/289944-check_http.extented_status_codes.diff.3
@@ -0,0 +1,82 @@
1Index: THANKS.in
2===================================================================
3--- THANKS.in (revision 2045)
4+++ THANKS.in (working copy)
5@@ -237,3 +237,4 @@
6 Rob Windsor
7 Hilko Bengen
8 Michael Harris
9+Sven Nierlein
10Index: NEWS
11===================================================================
12--- NEWS (revision 2045)
13+++ NEWS (working copy)
14@@ -10,6 +10,7 @@
15 check_snmp now only prints perfdata for non numeric values (#1867716)
16 check_icmp now supports packet size modification
17 check_http now sends the Host header first to fix 301s on servers with vitrual hosts (Michael Harris).
18+ check_http -e now accepts a comma-delimited list of expected status codes
19 libtap now included with this distribution for easier testing. Run ./configure with --enable-libtap
20
21 1.4.12 27th May 2008
22Index: plugins/check_http.c
23===================================================================
24--- plugins/check_http.c (revision 2045)
25+++ plugins/check_http.c (working copy)
26@@ -573,8 +573,26 @@
27 }
28 }
29
30+/* Checks if the server 'reply' is one of the expected 'statuscodes' */
31+static int
32+expected_statuscode (const char *reply, const char *statuscodes)
33+{
34+ char *expected, *code;
35+ int result = 0;
36
37+ if ((expected = strdup (statuscodes)) == NULL)
38+ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Memory allocation error\n"));
39
40+ for (code = strtok (expected, ","); code != NULL; code = strtok (NULL, ","))
41+ if (strstr (reply, code) != NULL) {
42+ result = 1;
43+ break;
44+ }
45+
46+ free (expected);
47+ return result;
48+}
49+
50 static void
51 check_document_dates (const char *headers)
52 {
53@@ -878,14 +896,15 @@
54 (no_body ? " [[ skipped ]]" : page));
55
56 /* make sure the status line matches the response we are looking for */
57- if (!strstr (status_line, server_expect)) {
58+ if (!expected_statuscode (status_line, server_expect)) {
59 if (server_port == HTTP_PORT)
60 asprintf (&msg,
61- _("Invalid HTTP response received from host\n"));
62+ _("Invalid HTTP response received from host: %s\n"),
63+ status_line);
64 else
65 asprintf (&msg,
66- _("Invalid HTTP response received from host on port %d\n"),
67- server_port);
68+ _("Invalid HTTP response received from host on port %d: %s\n"),
69+ server_port, status_line);
70 die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg);
71 }
72
73@@ -1262,7 +1281,8 @@
74 #endif
75
76 printf (" %s\n", "-e, --expect=STRING");
77- printf (" %s\n", _("String to expect in first (status) line of server response (default: "));
78+ printf (" %s\n", _("Comma-delimited list of strings, at least one of them is expected in"));
79+ printf (" %s\n", _("the first (status) line of the server response (default: "));
80 printf ("%s)\n", HTTP_EXPECT);
81 printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)"));
82 printf (" %s\n", "-s, --string=STRING");