From 0b6423f9c99d9edf8c96fefd0f6c453859395aa1 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 30 Sep 2013 00:03:24 +0200 Subject: Import Nagios Plugins site Import the Nagios Plugins web site, Cronjobs, infrastructure scripts, and configuration files. --- .../289944-check_http.extented_status_codes.diff.3 | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 web/attachments/289944-check_http.extented_status_codes.diff.3 (limited to 'web/attachments/289944-check_http.extented_status_codes.diff.3') 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 @@ +Index: THANKS.in +=================================================================== +--- THANKS.in (revision 2045) ++++ THANKS.in (working copy) +@@ -237,3 +237,4 @@ + Rob Windsor + Hilko Bengen + Michael Harris ++Sven Nierlein +Index: NEWS +=================================================================== +--- NEWS (revision 2045) ++++ NEWS (working copy) +@@ -10,6 +10,7 @@ + check_snmp now only prints perfdata for non numeric values (#1867716) + check_icmp now supports packet size modification + check_http now sends the Host header first to fix 301s on servers with vitrual hosts (Michael Harris). ++ check_http -e now accepts a comma-delimited list of expected status codes + libtap now included with this distribution for easier testing. Run ./configure with --enable-libtap + + 1.4.12 27th May 2008 +Index: plugins/check_http.c +=================================================================== +--- plugins/check_http.c (revision 2045) ++++ plugins/check_http.c (working copy) +@@ -573,8 +573,26 @@ + } + } + ++/* Checks if the server 'reply' is one of the expected 'statuscodes' */ ++static int ++expected_statuscode (const char *reply, const char *statuscodes) ++{ ++ char *expected, *code; ++ int result = 0; + ++ if ((expected = strdup (statuscodes)) == NULL) ++ die (STATE_UNKNOWN, _("HTTP UNKNOWN - Memory allocation error\n")); + ++ for (code = strtok (expected, ","); code != NULL; code = strtok (NULL, ",")) ++ if (strstr (reply, code) != NULL) { ++ result = 1; ++ break; ++ } ++ ++ free (expected); ++ return result; ++} ++ + static void + check_document_dates (const char *headers) + { +@@ -878,14 +896,15 @@ + (no_body ? " [[ skipped ]]" : page)); + + /* make sure the status line matches the response we are looking for */ +- if (!strstr (status_line, server_expect)) { ++ if (!expected_statuscode (status_line, server_expect)) { + if (server_port == HTTP_PORT) + asprintf (&msg, +- _("Invalid HTTP response received from host\n")); ++ _("Invalid HTTP response received from host: %s\n"), ++ status_line); + else + asprintf (&msg, +- _("Invalid HTTP response received from host on port %d\n"), +- server_port); ++ _("Invalid HTTP response received from host on port %d: %s\n"), ++ server_port, status_line); + die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); + } + +@@ -1262,7 +1281,8 @@ + #endif + + printf (" %s\n", "-e, --expect=STRING"); +- printf (" %s\n", _("String to expect in first (status) line of server response (default: ")); ++ printf (" %s\n", _("Comma-delimited list of strings, at least one of them is expected in")); ++ printf (" %s\n", _("the first (status) line of the server response (default: ")); + printf ("%s)\n", HTTP_EXPECT); + printf (" %s\n", _("If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)")); + printf (" %s\n", "-s, --string=STRING"); -- cgit v1.2.3-74-g34f1