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. --- web/attachments/34095-check_http.c.patch | 140 +++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 web/attachments/34095-check_http.c.patch (limited to 'web/attachments/34095-check_http.c.patch') 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 @@ +--- plutins/check_http.c 2002-10-28 18:02:11.000000000 +0100 ++++ plugins/check_http.c 2002-10-28 19:42:30.000000000 +0100 +@@ -44,7 +44,7 @@ + \(-H | -I ) [-u ] [-p ]\n\ + [-w ] [-c ] [-t ] [-L]\n\ + [-a auth] [-f ] [-e ]\n\ +- [-s string] [-r | -R ]\n\ ++ [-s string] [-r | -R ] [-x]\n\ + [-P string]" + + #define LONGOPTIONS "\ +@@ -71,6 +71,8 @@ + Seconds before connection times out (default: %d)\n\ + -a, --authorization=AUTH_PAIR\n\ + Username:password on sites with basic authentication\n\ ++ -x, --reverse\n\ ++ Reverse the result of -r|-R|-s (like grep -v)\n\ + -L, --link=URL\n\ + Wrap output in HTML link (obsoleted by urlize)\n\ + -f, --onredirect=\n\ +@@ -190,6 +192,7 @@ + int server_expect_yn = 0; + char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; + char string_expect[MAX_INPUT_BUFFER] = ""; ++int found_reverse = FALSE; /* grep -v */ + double warning_time = 0; + int check_warning_time = FALSE; + double critical_time = 0; +@@ -287,6 +290,7 @@ + {"regex", required_argument, 0, 'r'}, + {"ereg", required_argument, 0, 'r'}, + {"eregi", required_argument, 0, 'R'}, ++ {"reverse", no_argument, 0, 'x'}, + {"onredirect", required_argument, 0, 'f'}, + {"certificate", required_argument, 0, 'C'}, + {0, 0, 0, 0} +@@ -309,7 +313,7 @@ + strcpy (argv[c], "-n"); + } + +-#define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nLS" ++#define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nLSx" + + while (1) { + #ifdef HAVE_GETOPT_H +@@ -442,6 +446,9 @@ + usage ("check_http: call for regex which was not a compiled option\n"); + #endif + break; ++ case 'x': /* grep -v */ ++ found_reverse = TRUE; ++ break; + case 'v': /* verbose */ + verbose = TRUE; + break; +@@ -849,31 +856,69 @@ + + if (strlen (string_expect)) { + if (strstr (page, string_expect)) { +- printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", +- status_line, elapsed_time, +- timestamp, (display_html ? "" : ""), elapsed_time); +- exit (STATE_OK); ++ if (found_reverse) { /* grep -v */ ++ printf ("HTTP CRITICAL: string found%s|time=%7.3f\n", ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_CRITICAL) ; ++ } else { ++ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", ++ status_line, elapsed_time, ++ timestamp, ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_OK); ++ } + } +- else { +- printf ("HTTP CRITICAL: string not found%s|time=%7.3f\n", +- (display_html ? "" : ""), elapsed_time); +- exit (STATE_CRITICAL); ++ else { /* not found */ ++ if (found_reverse) { /* grep -v */ ++ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", ++ status_line, elapsed_time, ++ timestamp, ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_OK) ; ++ } else { ++ printf ("HTTP CRITICAL: string not found%s|time=%7.3f\n", ++ (display_html ? "" : ""), elapsed_time); ++ exit (STATE_CRITICAL); ++ } + } + } + #ifdef HAVE_REGEX_H + if (strlen (regexp)) { + errcode = regexec (&preg, page, REGS, pmatch, 0); + if (errcode == 0) { +- printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", +- status_line, elapsed_time, +- timestamp, (display_html ? "" : ""), elapsed_time); +- exit (STATE_OK); ++ if (found_reverse) { /* grep -v */ ++ printf ("HTTP CRITICAL: pattern found%s|time=%7.3f\n", ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_CRITICAL); ++ } else { ++ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", ++ status_line, elapsed_time, ++ timestamp, ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_OK); ++ } + } + else { + if (errcode == REG_NOMATCH) { +- printf ("HTTP CRITICAL: pattern not found%s|time=%7.3f\n", +- (display_html ? "" : ""), elapsed_time); +- exit (STATE_CRITICAL); ++ if (found_reverse) { /* grep -v */ ++ printf ("HTTP ok: %s - %7.3f second response time %s%s|time=%7.3f\n", ++ status_line, elapsed_time, ++ timestamp, ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_OK); ++ ++ } else { ++ printf ("HTTP CRITICAL: pattern not found%s|time=%7.3f\n", ++ (display_html ? "" : ""), ++ elapsed_time); ++ exit (STATE_CRITICAL); ++ } + } + else { + regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); -- cgit v1.2.3-74-g34f1