diff options
Diffstat (limited to 'web/attachments/289932-check_http.extented_status_codes.diff.2')
| -rw-r--r-- | web/attachments/289932-check_http.extented_status_codes.diff.2 | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/web/attachments/289932-check_http.extented_status_codes.diff.2 b/web/attachments/289932-check_http.extented_status_codes.diff.2 new file mode 100644 index 0000000..a703883 --- /dev/null +++ b/web/attachments/289932-check_http.extented_status_codes.diff.2 | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | Index: 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 | ||
| 10 | Index: 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 | ||
| 22 | Index: plugins/check_http.c | ||
| 23 | =================================================================== | ||
| 24 | --- plugins/check_http.c (revision 2045) | ||
| 25 | +++ plugins/check_http.c (working copy) | ||
| 26 | @@ -573,8 +573,22 @@ | ||
| 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 | |||
| 36 | + if ((expected = strdup (statuscodes)) == NULL) | ||
| 37 | + die (STATE_UNKNOWN, _("HTTP UNKNOWN - Memory allocation error\n")); | ||
| 38 | |||
| 39 | + for (code = strtok (expected, ","); code != NULL; code = strtok (NULL, ",")) | ||
| 40 | + if (strstr (reply, code) != NULL) | ||
| 41 | + return 1; | ||
| 42 | + | ||
| 43 | + return 0; | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | static void | ||
| 47 | check_document_dates (const char *headers) | ||
| 48 | { | ||
| 49 | @@ -878,14 +892,15 @@ | ||
| 50 | (no_body ? " [[ skipped ]]" : page)); | ||
| 51 | |||
| 52 | /* make sure the status line matches the response we are looking for */ | ||
| 53 | - if (!strstr (status_line, server_expect)) { | ||
| 54 | + if (!expected_statuscode (status_line, server_expect)) { | ||
| 55 | if (server_port == HTTP_PORT) | ||
| 56 | asprintf (&msg, | ||
| 57 | - _("Invalid HTTP response received from host\n")); | ||
| 58 | + _("Invalid HTTP response received from host: %s\n"), | ||
| 59 | + status_line); | ||
| 60 | else | ||
| 61 | asprintf (&msg, | ||
| 62 | - _("Invalid HTTP response received from host on port %d\n"), | ||
| 63 | - server_port); | ||
| 64 | + _("Invalid HTTP response received from host on port %d: %s\n"), | ||
| 65 | + server_port, status_line); | ||
| 66 | die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); | ||
| 67 | } | ||
| 68 | |||
| 69 | @@ -1262,7 +1277,8 @@ | ||
| 70 | #endif | ||
| 71 | |||
| 72 | printf (" %s\n", "-e, --expect=STRING"); | ||
| 73 | - printf (" %s\n", _("String to expect in first (status) line of server response (default: ")); | ||
| 74 | + printf (" %s\n", _("Comma-delimited list of strings, at least one of them is expected in")); | ||
| 75 | + printf (" %s\n", _("the first (status) line of the server response (default: ")); | ||
| 76 | printf ("%s)\n", HTTP_EXPECT); | ||
| 77 | printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); | ||
| 78 | printf (" %s\n", "-s, --string=STRING"); | ||
