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/26227-check_procs-pch.txt | 135 ++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 web/attachments/26227-check_procs-pch.txt (limited to 'web/attachments/26227-check_procs-pch.txt') diff --git a/web/attachments/26227-check_procs-pch.txt b/web/attachments/26227-check_procs-pch.txt new file mode 100644 index 0000000..e3f8bd1 --- /dev/null +++ b/web/attachments/26227-check_procs-pch.txt @@ -0,0 +1,135 @@ +--- plugins/check_procs.c.orig Tue Jun 11 09:08:00 2002 ++++ plugins/check_procs.c Tue Jun 11 13:47:52 2002 +@@ -68,6 +68,14 @@ + char *format = NULL; + char tmp[MAX_INPUT_BUFFER]; + ++#ifdef HAVE_REGEX_H ++#include ++regex_t argsre, progre; ++int cflags = 0; ++char errbuf[MAX_INPUT_BUFFER]; ++int excode; ++#endif ++ + int + main (int argc, char **argv) + { +@@ -91,6 +99,21 @@ + if (process_arguments (argc, argv) == ERROR) + usage ("Unable to parse command line\n"); + ++#if HAVE_REGEX_H ++ if ((options & ARGS) && cflags) { ++ if ((excode = regcomp (&argsre, args, cflags)) != 0) { ++ printf ("Could Not Compile Regular Expression\n"); ++ return STATE_UNKNOWN; ++ } ++ } ++ if ((options & PROG) && cflags) { ++ if ((excode = regcomp (&progre, prog, cflags)) != 0) { ++ printf ("Could Not Compile Regular Expression\n"); ++ return STATE_UNKNOWN; ++ } ++ } ++#endif ++ + /* run the command */ + if (verbose) + printf ("%s\n", PS_COMMAND); +@@ -121,10 +144,34 @@ + strip (procargs); + if ((options & STAT) && (strstr (statopts, procstat))) + resultsum |= STAT; +- if ((options & ARGS) && (strstr (procargs, args) == procargs)) ++ if ((options & ARGS) && !cflags && (strstr (procargs, args) == procargs)) + resultsum |= ARGS; +- if ((options & PROG) && (strcmp (prog, procprog) == 0)) ++ if ((options & PROG) && !cflags && (strcmp (prog, procprog) == 0)) + resultsum |= PROG; ++#if HAVE_REGEX_H ++ if ((options & ARGS) && cflags) { ++ excode = regexec (&argsre, procargs, (size_t) 0, NULL, 0); ++ if (excode == 0) { ++ resultsum |= ARGS; ++ } ++ else if (excode != REG_NOMATCH) { ++ regerror (excode, &argsre, errbuf, MAX_INPUT_BUFFER); ++ printf ("Execute Error: %s\n", errbuf); ++ exit (STATE_CRITICAL); ++ } ++ } ++ if ((options & PROG) && cflags) { ++ excode = regexec (&progre, procprog, (size_t) 0, NULL, 0); ++ if (excode == 0) { ++ resultsum |= PROG; ++ } ++ else if (excode != REG_NOMATCH) { ++ regerror (excode, &argsre, errbuf, MAX_INPUT_BUFFER); ++ printf ("Execute Error: %s\n", errbuf); ++ exit (STATE_CRITICAL); ++ } ++ } ++#endif + if ((options & PPID) && (procppid == ppid)) + resultsum |= PPID; + if ((options & USER) && (procuid == uid)) +@@ -263,6 +310,9 @@ + {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'V'}, + {"verbose", no_argument, 0, 'v'}, ++ {"regex", no_argument, 0, 'r'}, ++ {"ereg", no_argument, 0, 'r'}, ++ {"eregi", no_argument, 0, 'R'}, + {0, 0, 0, 0} + }; + #endif +@@ -270,10 +320,10 @@ + while (1) { + #ifdef HAVE_GETOPT_H + c = +- getopt_long (argc, argv, "+Vvht:c:w:p:s:u:C:a:", long_options, ++ getopt_long (argc, argv, "+VvhRrt:c:w:p:s:u:C:a:", long_options, + &option_index); + #else +- c = getopt (argc, argv, "+Vvht:c:w:p:s:u:C:a:"); ++ c = getopt (argc, argv, "+VvhRrt:c:w:p:s:u:C:a:"); + #endif + + if (c == EOF) +@@ -419,6 +469,22 @@ + case 'v': /* command */ + verbose = TRUE; + break; ++ case 'R': /* regex */ ++#ifdef HAVE_REGEX_H ++ cflags = REG_ICASE | REG_EXTENDED | REG_NOSUB | REG_NEWLINE; ++#else ++ printf ("PROCS UNKNOWN: call for regex which was not a compiled option"); ++ exit (STATE_UNKNOWN); ++#endif ++ break; ++ case 'r': /* regex */ ++#ifdef HAVE_REGEX_H ++ cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; ++#else ++ printf ("PROCS UNKNOWN: call for regex which was not a compiled option"); ++ exit (STATE_UNKNOWN); ++#endif ++ break; + } + } + return i; +@@ -492,7 +558,11 @@ + " -a, --argument-array=STRING\n" + " Only scan for ARGS that match up to the length of the given STRING\n" + " -C, --command=COMMAND\n" +- " Only scan for exact matches to the named COMMAND.\n\n" ++ " Only scan for exact matches to the named COMMAND.\n" ++ " -r, --ereg\n" ++ " Treat the -a or -C argument as an extended regular expression\n" ++ " -R, --eregi\n" ++ " Treat the -a or -C argument as a case-insensitive extended regular expression\n\n" + "RANGEs are specified 'min:max' or 'min:' or ':max' (or 'max'). If\n" + "specified 'max:min', a warning status will be generated if the\n" + -- cgit v1.2.3-74-g34f1