diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2006-05-25 12:33:24 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2006-05-25 12:33:24 +0000 |
commit | 5fd2550d4c96318b2de4a4a44e15e3c50c268e79 (patch) | |
tree | b712838611281a444a9b603949352bc4003de657 /plugins | |
parent | 80e155c9cf826d977393ee130a07be599401335e (diff) | |
download | monitoring-plugins-5fd2550d4c96318b2de4a4a44e15e3c50c268e79.tar.gz |
Use coreutils' regexp libraries, so regexp always available now
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1403 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_apt.c | 2 | ||||
-rw-r--r-- | plugins/check_http.c | 17 | ||||
-rw-r--r-- | plugins/check_smtp.c | 11 | ||||
-rw-r--r-- | plugins/check_snmp.c | 16 |
4 files changed, 5 insertions, 41 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c index 445659d1..528dd60c 100644 --- a/plugins/check_apt.c +++ b/plugins/check_apt.c @@ -30,7 +30,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include "common.h" #include "runcmd.h" #include "utils.h" -#include <regex.h> +#include "regex.h" /* some constants */ typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; diff --git a/plugins/check_http.c b/plugins/check_http.c index e25e5db2..1869837e 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -51,19 +51,17 @@ X509 *server_cert; int no_body = FALSE; int maximum_age = -1; -#ifdef HAVE_REGEX_H enum { REGS = 2, MAX_RE_SIZE = 256 }; -#include <regex.h> +#include "regex.h" regex_t preg; regmatch_t pmatch[REGS]; char regexp[MAX_RE_SIZE]; char errbuf[MAX_INPUT_BUFFER]; int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; int errcode; -#endif struct timeval tv; @@ -333,13 +331,6 @@ process_arguments (int argc, char **argv) case 'T': /* Content-type */ asprintf (&http_content_type, "%s", optarg); break; -#ifndef HAVE_REGEX_H - case 'l': /* linespan */ - case 'r': /* linespan */ - case 'R': /* linespan */ - usage4 (_("Call for regex which was not a compiled option")); - break; -#else case 'l': /* linespan */ cflags &= ~REG_NEWLINE; break; @@ -355,7 +346,6 @@ process_arguments (int argc, char **argv) return ERROR; } break; -#endif case '4': address_family = AF_INET; break; @@ -992,7 +982,7 @@ check_http (void) exit (STATE_CRITICAL); } } -#ifdef HAVE_REGEX_H + if (strlen (regexp)) { errcode = regexec (&preg, page, REGS, pmatch, 0); if (errcode == 0) { @@ -1016,7 +1006,6 @@ check_http (void) } } } -#endif /* make sure the page is of an appropriate size */ /* page_len = get_content_length(header); */ @@ -1270,7 +1259,6 @@ certificate expiration times.")); -T, --content-type=STRING\n\ specify Content-Type header media type when POSTing\n"), HTTP_EXPECT); -#ifdef HAVE_REGEX_H printf (_("\ -l, --linespan\n\ Allow regex to span newlines (must precede -r or -R)\n\ @@ -1278,7 +1266,6 @@ certificate expiration times.")); Search page for regex STRING\n\ -R, --eregi=STRING\n\ Search page for case-insensitive regex STRING\n")); -#endif printf (_("\ -a, --authorization=AUTH_PAIR\n\ diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index e99f0675..3dc444fc 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c @@ -59,8 +59,7 @@ void print_help (void); void print_usage (void); int my_close(void); -#ifdef HAVE_REGEX_H -#include <regex.h> +#include "regex.h" char regex_expect[MAX_INPUT_BUFFER] = ""; regex_t preg; regmatch_t pmatch[10]; @@ -69,7 +68,6 @@ char errbuf[MAX_INPUT_BUFFER]; int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; int eflags = 0; int errcode, excode; -#endif int server_port = SMTP_PORT; char *server_address = NULL; @@ -308,7 +306,6 @@ main (int argc, char **argv) printf("%s", buffer); strip (buffer); if (n < nresponses) { -#ifdef HAVE_REGEX_H cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; errcode = regcomp (&preg, responses[n], cflags); if (errcode != 0) { @@ -329,12 +326,6 @@ main (int argc, char **argv) printf (_("Execute Error: %s\n"), errbuf); result = STATE_UNKNOWN; } -#else - if (strstr(buffer, responses[n])!=buffer) { - result = STATE_WARNING; - printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]); - } -#endif } n++; } diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index b53fb112..9ff3439e 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c @@ -75,8 +75,7 @@ char *nextarg (char *str); void print_usage (void); void print_help (void); -#ifdef HAVE_REGEX_H -#include <regex.h> +#include "regex.h" char regex_expect[MAX_INPUT_BUFFER] = ""; regex_t preg; regmatch_t pmatch[10]; @@ -86,7 +85,6 @@ char perfstr[MAX_INPUT_BUFFER]; int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; int eflags = 0; int errcode, excode; -#endif char *server_address = NULL; char *community = NULL; @@ -292,7 +290,6 @@ main (int argc, char **argv) /* Process this block for regex matching */ else if (eval_method[i] & CRIT_REGEX) { -#ifdef HAVE_REGEX_H excode = regexec (&preg, response, 10, pmatch, eflags); if (excode == 0) { iresult = STATE_OK; @@ -305,10 +302,6 @@ main (int argc, char **argv) else { iresult = STATE_CRITICAL; } -#else - printf (_("Call for regex which was not a compiled option")); - exit (STATE_UNKNOWN); -#endif } /* Process this block for existence-nonexistence checks */ @@ -542,11 +535,8 @@ process_arguments (int argc, char **argv) ii++; break; case 'R': /* regex */ -#ifdef HAVE_REGEX_H cflags = REG_ICASE; -#endif case 'r': /* regex */ -#ifdef HAVE_REGEX_H cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; strncpy (regex_expect, optarg, sizeof (regex_expect) - 1); regex_expect[sizeof (regex_expect) - 1] = 0; @@ -558,10 +548,6 @@ process_arguments (int argc, char **argv) } eval_method[jj++] = CRIT_REGEX; ii++; -#else - printf (_("call for regex which was not a compiled option")); - exit (STATE_UNKNOWN); -#endif break; /* Format */ |