aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-01-16 06:29:02 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-01-16 06:29:02 +0000
commit68544fbb90b4a702de4a939d5c62055e453582c6 (patch)
treebc3882c647726a63d4fe65730e994a8bb0c75c4b
parentec1ff298a54e901218a56d5c0831d0a6dec48e92 (diff)
downloadmonitoring-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
-rw-r--r--plugins/check_http.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index de7a2db7..2259c6ff 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -44,7 +44,7 @@ certificate expiration times.\n"
\(-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
[-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
[-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
- [-s string] [-r <regex> | -R <case-insensitive regex>]\n\
+ [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
[-P string]"
#define LONGOPTIONS "\
@@ -74,7 +74,7 @@ certificate expiration times.\n"
-L, --link=URL\n\
Wrap output in HTML link (obsoleted by urlize)\n\
-f, --onredirect=<ok|warning|critical|follow>\n\
- How to handle redirected pages\n%s\
+ How to handle redirected pages\n%s%s\
-v, --verbose\n\
Show details for command-line debugging (do not use with nagios server)\n\
-h, --help\n\
@@ -93,6 +93,18 @@ certificate expiration times.\n"
#define SSLOPTIONS ""
#endif
+#ifdef HAVE_REGEX_H
+#define REGOPTIONS "\
+ -l, --linespan\n\
+ Allow regex to span newlines (must precede -r or -R)\n\
+ -r, --regex, --ereg=STRING\n\
+ Search page for regex STRING\n\
+ -R, --eregi=STRING\n\
+ Search page for case-insensitive regex STRING\n"
+#else
+#define REGOPTIONS ""
+#endif
+
#define DESCRIPTION "\
This plugin will attempt to open an HTTP connection with the host. Successul\n\
connects return STATE_OK, refusals and timeouts return STATE_CRITICAL, other\n\
@@ -286,6 +298,7 @@ process_arguments (int argc, char **argv)
{"regex", required_argument, 0, 'r'},
{"ereg", required_argument, 0, 'r'},
{"eregi", required_argument, 0, 'R'},
+ {"linespan", no_argument, 0, 'l'},
{"onredirect", required_argument, 0, 'f'},
{"certificate", required_argument, 0, 'C'},
{0, 0, 0, 0}
@@ -308,7 +321,7 @@ process_arguments (int argc, char **argv)
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:nlLS"
while (1) {
#ifdef HAVE_GETOPT_H
@@ -420,15 +433,19 @@ process_arguments (int argc, char **argv)
server_expect[MAX_INPUT_BUFFER - 1] = 0;
server_expect_yn = 1;
break;
- case 'R': /* regex */
-#ifdef HAVE_REGEX_H
- cflags = REG_ICASE;
-#else
+#ifndef HAVE_REGEX_H
+ case 'l': /* linespan */
+ case 'r': /* linespan */
+ case 'R': /* linespan */
usage ("check_http: call for regex which was not a compiled option\n");
-#endif
+ break;
+#else
+ case 'l': /* linespan */
+ cflags &= ~REG_NEWLINE;
+ break;
+ case 'R': /* regex */
+ cflags |= REG_ICASE;
case 'r': /* regex */
-#ifdef HAVE_REGEX_H
- cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
strncpy (regexp, optarg, MAX_RE_SIZE - 1);
regexp[MAX_RE_SIZE - 1] = 0;
errcode = regcomp (&preg, regexp, cflags);
@@ -437,10 +454,8 @@ process_arguments (int argc, char **argv)
printf ("Could Not Compile Regular Expression: %s", errbuf);
return ERROR;
}
-#else
- usage ("check_http: call for regex which was not a compiled option\n");
-#endif
break;
+#endif
case 'v': /* verbose */
verbose = TRUE;
break;
@@ -449,8 +464,7 @@ process_arguments (int argc, char **argv)
c = optind;
- if (server_address == NULL && host_name == NULL) {
- server_address = strscpy (NULL, argv[c]);
+ if (server_address == NULL && host_name == NULL) { server_address = strscpy (NULL, argv[c]);
host_name = strscpy (NULL, argv[c++]);
}
@@ -1065,7 +1079,7 @@ print_help (void)
print_usage ();
printf ("NOTE: One or both of -H and -I must be specified\n");
printf ("\nOptions:\n" LONGOPTIONS "\n", HTTP_EXPECT, HTTP_PORT,
- DEFAULT_SOCKET_TIMEOUT, SSLOPTIONS);
+ DEFAULT_SOCKET_TIMEOUT, SSLOPTIONS, REGOPTIONS);
#ifdef HAVE_SSL
printf (SSLDESCRIPTION);
#endif