diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-01-16 06:29:02 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-01-16 06:29:02 (GMT) |
commit | 68544fbb90b4a702de4a939d5c62055e453582c6 (patch) | |
tree | bc3882c647726a63d4fe65730e994a8bb0c75c4b /plugins | |
parent | ec1ff298a54e901218a56d5c0831d0a6dec48e92 (diff) | |
download | monitoring-plugins-68544fbb90b4a702de4a939d5c62055e453582c6.tar.gz |
add option to let regex span newlines
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@248 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_http.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index de7a2db..2259c6f 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -44,7 +44,7 @@ certificate expiration times.\n" | |||
44 | \(-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\ | 44 | \(-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\ |
45 | [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\ | 45 | [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\ |
46 | [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\ | 46 | [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\ |
47 | [-s string] [-r <regex> | -R <case-insensitive regex>]\n\ | 47 | [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\ |
48 | [-P string]" | 48 | [-P string]" |
49 | 49 | ||
50 | #define LONGOPTIONS "\ | 50 | #define LONGOPTIONS "\ |
@@ -74,7 +74,7 @@ certificate expiration times.\n" | |||
74 | -L, --link=URL\n\ | 74 | -L, --link=URL\n\ |
75 | Wrap output in HTML link (obsoleted by urlize)\n\ | 75 | Wrap output in HTML link (obsoleted by urlize)\n\ |
76 | -f, --onredirect=<ok|warning|critical|follow>\n\ | 76 | -f, --onredirect=<ok|warning|critical|follow>\n\ |
77 | How to handle redirected pages\n%s\ | 77 | How to handle redirected pages\n%s%s\ |
78 | -v, --verbose\n\ | 78 | -v, --verbose\n\ |
79 | Show details for command-line debugging (do not use with nagios server)\n\ | 79 | Show details for command-line debugging (do not use with nagios server)\n\ |
80 | -h, --help\n\ | 80 | -h, --help\n\ |
@@ -93,6 +93,18 @@ certificate expiration times.\n" | |||
93 | #define SSLOPTIONS "" | 93 | #define SSLOPTIONS "" |
94 | #endif | 94 | #endif |
95 | 95 | ||
96 | #ifdef HAVE_REGEX_H | ||
97 | #define REGOPTIONS "\ | ||
98 | -l, --linespan\n\ | ||
99 | Allow regex to span newlines (must precede -r or -R)\n\ | ||
100 | -r, --regex, --ereg=STRING\n\ | ||
101 | Search page for regex STRING\n\ | ||
102 | -R, --eregi=STRING\n\ | ||
103 | Search page for case-insensitive regex STRING\n" | ||
104 | #else | ||
105 | #define REGOPTIONS "" | ||
106 | #endif | ||
107 | |||
96 | #define DESCRIPTION "\ | 108 | #define DESCRIPTION "\ |
97 | This plugin will attempt to open an HTTP connection with the host. Successul\n\ | 109 | This plugin will attempt to open an HTTP connection with the host. Successul\n\ |
98 | connects return STATE_OK, refusals and timeouts return STATE_CRITICAL, other\n\ | 110 | connects return STATE_OK, refusals and timeouts return STATE_CRITICAL, other\n\ |
@@ -286,6 +298,7 @@ process_arguments (int argc, char **argv) | |||
286 | {"regex", required_argument, 0, 'r'}, | 298 | {"regex", required_argument, 0, 'r'}, |
287 | {"ereg", required_argument, 0, 'r'}, | 299 | {"ereg", required_argument, 0, 'r'}, |
288 | {"eregi", required_argument, 0, 'R'}, | 300 | {"eregi", required_argument, 0, 'R'}, |
301 | {"linespan", no_argument, 0, 'l'}, | ||
289 | {"onredirect", required_argument, 0, 'f'}, | 302 | {"onredirect", required_argument, 0, 'f'}, |
290 | {"certificate", required_argument, 0, 'C'}, | 303 | {"certificate", required_argument, 0, 'C'}, |
291 | {0, 0, 0, 0} | 304 | {0, 0, 0, 0} |
@@ -308,7 +321,7 @@ process_arguments (int argc, char **argv) | |||
308 | strcpy (argv[c], "-n"); | 321 | strcpy (argv[c], "-n"); |
309 | } | 322 | } |
310 | 323 | ||
311 | #define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nLS" | 324 | #define OPTCHARS "Vvht:c:w:H:P:I:a:e:p:s:R:r:u:f:C:nlLS" |
312 | 325 | ||
313 | while (1) { | 326 | while (1) { |
314 | #ifdef HAVE_GETOPT_H | 327 | #ifdef HAVE_GETOPT_H |
@@ -420,15 +433,19 @@ process_arguments (int argc, char **argv) | |||
420 | server_expect[MAX_INPUT_BUFFER - 1] = 0; | 433 | server_expect[MAX_INPUT_BUFFER - 1] = 0; |
421 | server_expect_yn = 1; | 434 | server_expect_yn = 1; |
422 | break; | 435 | break; |
423 | case 'R': /* regex */ | 436 | #ifndef HAVE_REGEX_H |
424 | #ifdef HAVE_REGEX_H | 437 | case 'l': /* linespan */ |
425 | cflags = REG_ICASE; | 438 | case 'r': /* linespan */ |
426 | #else | 439 | case 'R': /* linespan */ |
427 | usage ("check_http: call for regex which was not a compiled option\n"); | 440 | usage ("check_http: call for regex which was not a compiled option\n"); |
428 | #endif | 441 | break; |
442 | #else | ||
443 | case 'l': /* linespan */ | ||
444 | cflags &= ~REG_NEWLINE; | ||
445 | break; | ||
446 | case 'R': /* regex */ | ||
447 | cflags |= REG_ICASE; | ||
429 | case 'r': /* regex */ | 448 | case 'r': /* regex */ |
430 | #ifdef HAVE_REGEX_H | ||
431 | cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE; | ||
432 | strncpy (regexp, optarg, MAX_RE_SIZE - 1); | 449 | strncpy (regexp, optarg, MAX_RE_SIZE - 1); |
433 | regexp[MAX_RE_SIZE - 1] = 0; | 450 | regexp[MAX_RE_SIZE - 1] = 0; |
434 | errcode = regcomp (&preg, regexp, cflags); | 451 | errcode = regcomp (&preg, regexp, cflags); |
@@ -437,10 +454,8 @@ process_arguments (int argc, char **argv) | |||
437 | printf ("Could Not Compile Regular Expression: %s", errbuf); | 454 | printf ("Could Not Compile Regular Expression: %s", errbuf); |
438 | return ERROR; | 455 | return ERROR; |
439 | } | 456 | } |
440 | #else | ||
441 | usage ("check_http: call for regex which was not a compiled option\n"); | ||
442 | #endif | ||
443 | break; | 457 | break; |
458 | #endif | ||
444 | case 'v': /* verbose */ | 459 | case 'v': /* verbose */ |
445 | verbose = TRUE; | 460 | verbose = TRUE; |
446 | break; | 461 | break; |
@@ -449,8 +464,7 @@ process_arguments (int argc, char **argv) | |||
449 | 464 | ||
450 | c = optind; | 465 | c = optind; |
451 | 466 | ||
452 | if (server_address == NULL && host_name == NULL) { | 467 | if (server_address == NULL && host_name == NULL) { server_address = strscpy (NULL, argv[c]); |
453 | server_address = strscpy (NULL, argv[c]); | ||
454 | host_name = strscpy (NULL, argv[c++]); | 468 | host_name = strscpy (NULL, argv[c++]); |
455 | } | 469 | } |
456 | 470 | ||
@@ -1065,7 +1079,7 @@ print_help (void) | |||
1065 | print_usage (); | 1079 | print_usage (); |
1066 | printf ("NOTE: One or both of -H and -I must be specified\n"); | 1080 | printf ("NOTE: One or both of -H and -I must be specified\n"); |
1067 | printf ("\nOptions:\n" LONGOPTIONS "\n", HTTP_EXPECT, HTTP_PORT, | 1081 | printf ("\nOptions:\n" LONGOPTIONS "\n", HTTP_EXPECT, HTTP_PORT, |
1068 | DEFAULT_SOCKET_TIMEOUT, SSLOPTIONS); | 1082 | DEFAULT_SOCKET_TIMEOUT, SSLOPTIONS, REGOPTIONS); |
1069 | #ifdef HAVE_SSL | 1083 | #ifdef HAVE_SSL |
1070 | printf (SSLDESCRIPTION); | 1084 | printf (SSLDESCRIPTION); |
1071 | #endif | 1085 | #endif |