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"; | |||
| 30 | #include "common.h" | 30 | #include "common.h" |
| 31 | #include "runcmd.h" | 31 | #include "runcmd.h" |
| 32 | #include "utils.h" | 32 | #include "utils.h" |
| 33 | #include <regex.h> | 33 | #include "regex.h" |
| 34 | 34 | ||
| 35 | /* some constants */ | 35 | /* some constants */ |
| 36 | typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type; | 36 | 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; | |||
| 51 | int no_body = FALSE; | 51 | int no_body = FALSE; |
| 52 | int maximum_age = -1; | 52 | int maximum_age = -1; |
| 53 | 53 | ||
| 54 | #ifdef HAVE_REGEX_H | ||
| 55 | enum { | 54 | enum { |
| 56 | REGS = 2, | 55 | REGS = 2, |
| 57 | MAX_RE_SIZE = 256 | 56 | MAX_RE_SIZE = 256 |
| 58 | }; | 57 | }; |
| 59 | #include <regex.h> | 58 | #include "regex.h" |
| 60 | regex_t preg; | 59 | regex_t preg; |
| 61 | regmatch_t pmatch[REGS]; | 60 | regmatch_t pmatch[REGS]; |
| 62 | char regexp[MAX_RE_SIZE]; | 61 | char regexp[MAX_RE_SIZE]; |
| 63 | char errbuf[MAX_INPUT_BUFFER]; | 62 | char errbuf[MAX_INPUT_BUFFER]; |
| 64 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; | 63 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; |
| 65 | int errcode; | 64 | int errcode; |
| 66 | #endif | ||
| 67 | 65 | ||
| 68 | struct timeval tv; | 66 | struct timeval tv; |
| 69 | 67 | ||
| @@ -333,13 +331,6 @@ process_arguments (int argc, char **argv) | |||
| 333 | case 'T': /* Content-type */ | 331 | case 'T': /* Content-type */ |
| 334 | asprintf (&http_content_type, "%s", optarg); | 332 | asprintf (&http_content_type, "%s", optarg); |
| 335 | break; | 333 | break; |
| 336 | #ifndef HAVE_REGEX_H | ||
| 337 | case 'l': /* linespan */ | ||
| 338 | case 'r': /* linespan */ | ||
| 339 | case 'R': /* linespan */ | ||
| 340 | usage4 (_("Call for regex which was not a compiled option")); | ||
| 341 | break; | ||
| 342 | #else | ||
| 343 | case 'l': /* linespan */ | 334 | case 'l': /* linespan */ |
| 344 | cflags &= ~REG_NEWLINE; | 335 | cflags &= ~REG_NEWLINE; |
| 345 | break; | 336 | break; |
| @@ -355,7 +346,6 @@ process_arguments (int argc, char **argv) | |||
| 355 | return ERROR; | 346 | return ERROR; |
| 356 | } | 347 | } |
| 357 | break; | 348 | break; |
| 358 | #endif | ||
| 359 | case '4': | 349 | case '4': |
| 360 | address_family = AF_INET; | 350 | address_family = AF_INET; |
| 361 | break; | 351 | break; |
| @@ -992,7 +982,7 @@ check_http (void) | |||
| 992 | exit (STATE_CRITICAL); | 982 | exit (STATE_CRITICAL); |
| 993 | } | 983 | } |
| 994 | } | 984 | } |
| 995 | #ifdef HAVE_REGEX_H | 985 | |
| 996 | if (strlen (regexp)) { | 986 | if (strlen (regexp)) { |
| 997 | errcode = regexec (&preg, page, REGS, pmatch, 0); | 987 | errcode = regexec (&preg, page, REGS, pmatch, 0); |
| 998 | if (errcode == 0) { | 988 | if (errcode == 0) { |
| @@ -1016,7 +1006,6 @@ check_http (void) | |||
| 1016 | } | 1006 | } |
| 1017 | } | 1007 | } |
| 1018 | } | 1008 | } |
| 1019 | #endif | ||
| 1020 | 1009 | ||
| 1021 | /* make sure the page is of an appropriate size */ | 1010 | /* make sure the page is of an appropriate size */ |
| 1022 | /* page_len = get_content_length(header); */ | 1011 | /* page_len = get_content_length(header); */ |
| @@ -1270,7 +1259,6 @@ certificate expiration times.")); | |||
| 1270 | -T, --content-type=STRING\n\ | 1259 | -T, --content-type=STRING\n\ |
| 1271 | specify Content-Type header media type when POSTing\n"), HTTP_EXPECT); | 1260 | specify Content-Type header media type when POSTing\n"), HTTP_EXPECT); |
| 1272 | 1261 | ||
| 1273 | #ifdef HAVE_REGEX_H | ||
| 1274 | printf (_("\ | 1262 | printf (_("\ |
| 1275 | -l, --linespan\n\ | 1263 | -l, --linespan\n\ |
| 1276 | Allow regex to span newlines (must precede -r or -R)\n\ | 1264 | Allow regex to span newlines (must precede -r or -R)\n\ |
| @@ -1278,7 +1266,6 @@ certificate expiration times.")); | |||
| 1278 | Search page for regex STRING\n\ | 1266 | Search page for regex STRING\n\ |
| 1279 | -R, --eregi=STRING\n\ | 1267 | -R, --eregi=STRING\n\ |
| 1280 | Search page for case-insensitive regex STRING\n")); | 1268 | Search page for case-insensitive regex STRING\n")); |
| 1281 | #endif | ||
| 1282 | 1269 | ||
| 1283 | printf (_("\ | 1270 | printf (_("\ |
| 1284 | -a, --authorization=AUTH_PAIR\n\ | 1271 | -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); | |||
| 59 | void print_usage (void); | 59 | void print_usage (void); |
| 60 | int my_close(void); | 60 | int my_close(void); |
| 61 | 61 | ||
| 62 | #ifdef HAVE_REGEX_H | 62 | #include "regex.h" |
| 63 | #include <regex.h> | ||
| 64 | char regex_expect[MAX_INPUT_BUFFER] = ""; | 63 | char regex_expect[MAX_INPUT_BUFFER] = ""; |
| 65 | regex_t preg; | 64 | regex_t preg; |
| 66 | regmatch_t pmatch[10]; | 65 | regmatch_t pmatch[10]; |
| @@ -69,7 +68,6 @@ char errbuf[MAX_INPUT_BUFFER]; | |||
| 69 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 68 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
| 70 | int eflags = 0; | 69 | int eflags = 0; |
| 71 | int errcode, excode; | 70 | int errcode, excode; |
| 72 | #endif | ||
| 73 | 71 | ||
| 74 | int server_port = SMTP_PORT; | 72 | int server_port = SMTP_PORT; |
| 75 | char *server_address = NULL; | 73 | char *server_address = NULL; |
| @@ -308,7 +306,6 @@ main (int argc, char **argv) | |||
| 308 | printf("%s", buffer); | 306 | printf("%s", buffer); |
| 309 | strip (buffer); | 307 | strip (buffer); |
| 310 | if (n < nresponses) { | 308 | if (n < nresponses) { |
| 311 | #ifdef HAVE_REGEX_H | ||
| 312 | cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 309 | cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
| 313 | errcode = regcomp (&preg, responses[n], cflags); | 310 | errcode = regcomp (&preg, responses[n], cflags); |
| 314 | if (errcode != 0) { | 311 | if (errcode != 0) { |
| @@ -329,12 +326,6 @@ main (int argc, char **argv) | |||
| 329 | printf (_("Execute Error: %s\n"), errbuf); | 326 | printf (_("Execute Error: %s\n"), errbuf); |
| 330 | result = STATE_UNKNOWN; | 327 | result = STATE_UNKNOWN; |
| 331 | } | 328 | } |
| 332 | #else | ||
| 333 | if (strstr(buffer, responses[n])!=buffer) { | ||
| 334 | result = STATE_WARNING; | ||
| 335 | printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]); | ||
| 336 | } | ||
| 337 | #endif | ||
| 338 | } | 329 | } |
| 339 | n++; | 330 | n++; |
| 340 | } | 331 | } |
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); | |||
| 75 | void print_usage (void); | 75 | void print_usage (void); |
| 76 | void print_help (void); | 76 | void print_help (void); |
| 77 | 77 | ||
| 78 | #ifdef HAVE_REGEX_H | 78 | #include "regex.h" |
| 79 | #include <regex.h> | ||
| 80 | char regex_expect[MAX_INPUT_BUFFER] = ""; | 79 | char regex_expect[MAX_INPUT_BUFFER] = ""; |
| 81 | regex_t preg; | 80 | regex_t preg; |
| 82 | regmatch_t pmatch[10]; | 81 | regmatch_t pmatch[10]; |
| @@ -86,7 +85,6 @@ char perfstr[MAX_INPUT_BUFFER]; | |||
| 86 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 85 | int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
| 87 | int eflags = 0; | 86 | int eflags = 0; |
| 88 | int errcode, excode; | 87 | int errcode, excode; |
| 89 | #endif | ||
| 90 | 88 | ||
| 91 | char *server_address = NULL; | 89 | char *server_address = NULL; |
| 92 | char *community = NULL; | 90 | char *community = NULL; |
| @@ -292,7 +290,6 @@ main (int argc, char **argv) | |||
| 292 | 290 | ||
| 293 | /* Process this block for regex matching */ | 291 | /* Process this block for regex matching */ |
| 294 | else if (eval_method[i] & CRIT_REGEX) { | 292 | else if (eval_method[i] & CRIT_REGEX) { |
| 295 | #ifdef HAVE_REGEX_H | ||
| 296 | excode = regexec (&preg, response, 10, pmatch, eflags); | 293 | excode = regexec (&preg, response, 10, pmatch, eflags); |
| 297 | if (excode == 0) { | 294 | if (excode == 0) { |
| 298 | iresult = STATE_OK; | 295 | iresult = STATE_OK; |
| @@ -305,10 +302,6 @@ main (int argc, char **argv) | |||
| 305 | else { | 302 | else { |
| 306 | iresult = STATE_CRITICAL; | 303 | iresult = STATE_CRITICAL; |
| 307 | } | 304 | } |
| 308 | #else | ||
| 309 | printf (_("Call for regex which was not a compiled option")); | ||
| 310 | exit (STATE_UNKNOWN); | ||
| 311 | #endif | ||
| 312 | } | 305 | } |
| 313 | 306 | ||
| 314 | /* Process this block for existence-nonexistence checks */ | 307 | /* Process this block for existence-nonexistence checks */ |
| @@ -542,11 +535,8 @@ process_arguments (int argc, char **argv) | |||
| 542 | ii++; | 535 | ii++; |
| 543 | break; | 536 | break; |
| 544 | case 'R': /* regex */ | 537 | case 'R': /* regex */ |
| 545 | #ifdef HAVE_REGEX_H | ||
| 546 | cflags = REG_ICASE; | 538 | cflags = REG_ICASE; |
| 547 | #endif | ||
| 548 | case 'r': /* regex */ | 539 | case 'r': /* regex */ |
| 549 | #ifdef HAVE_REGEX_H | ||
| 550 | cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | 540 | cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; |
| 551 | strncpy (regex_expect, optarg, sizeof (regex_expect) - 1); | 541 | strncpy (regex_expect, optarg, sizeof (regex_expect) - 1); |
| 552 | regex_expect[sizeof (regex_expect) - 1] = 0; | 542 | regex_expect[sizeof (regex_expect) - 1] = 0; |
| @@ -558,10 +548,6 @@ process_arguments (int argc, char **argv) | |||
| 558 | } | 548 | } |
| 559 | eval_method[jj++] = CRIT_REGEX; | 549 | eval_method[jj++] = CRIT_REGEX; |
| 560 | ii++; | 550 | ii++; |
| 561 | #else | ||
| 562 | printf (_("call for regex which was not a compiled option")); | ||
| 563 | exit (STATE_UNKNOWN); | ||
| 564 | #endif | ||
| 565 | break; | 551 | break; |
| 566 | 552 | ||
| 567 | /* Format */ | 553 | /* Format */ |
