diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2024-04-07 18:01:54 (GMT) |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2024-04-07 18:01:54 (GMT) |
commit | f29785f5035e489576d2ba74be774273b73dd149 (patch) | |
tree | 70cb8a4857e22b224152731253dd627572907458 /plugins/check_curl.c | |
parent | 4c4031100a4520fe1e9a835e56b00e32b841f63e (diff) | |
download | monitoring-plugins-f29785f5035e489576d2ba74be774273b73dd149.tar.gz |
check_http/check_curl: added a --regex-state option to change the state of a regex check
from the default CRITICAL to something else (#1213)
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r-- | plugins/check_curl.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index d45a8fc..c54be5e 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -134,6 +134,7 @@ char regexp[MAX_RE_SIZE]; | |||
134 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; | 134 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; |
135 | int errcode; | 135 | int errcode; |
136 | bool invert_regex = false; | 136 | bool invert_regex = false; |
137 | int state_regex = STATE_CRITICAL; | ||
137 | 138 | ||
138 | char *server_address = NULL; | 139 | char *server_address = NULL; |
139 | char *host_name = NULL; | 140 | char *host_name = NULL; |
@@ -1133,7 +1134,7 @@ GOT_FIRST_CERT: | |||
1133 | strcpy(msg, tmp); | 1134 | strcpy(msg, tmp); |
1134 | 1135 | ||
1135 | } | 1136 | } |
1136 | result = STATE_CRITICAL; | 1137 | result = state_regex; |
1137 | } else { | 1138 | } else { |
1138 | regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); | 1139 | regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); |
1139 | 1140 | ||
@@ -1391,7 +1392,8 @@ process_arguments (int argc, char **argv) | |||
1391 | HTTP_VERSION_OPTION, | 1392 | HTTP_VERSION_OPTION, |
1392 | AUTOMATIC_DECOMPRESSION, | 1393 | AUTOMATIC_DECOMPRESSION, |
1393 | COOKIE_JAR, | 1394 | COOKIE_JAR, |
1394 | HAPROXY_PROTOCOL | 1395 | HAPROXY_PROTOCOL, |
1396 | STATE_REGEX | ||
1395 | }; | 1397 | }; |
1396 | 1398 | ||
1397 | int option = 0; | 1399 | int option = 0; |
@@ -1430,6 +1432,7 @@ process_arguments (int argc, char **argv) | |||
1430 | {"content-type", required_argument, 0, 'T'}, | 1432 | {"content-type", required_argument, 0, 'T'}, |
1431 | {"pagesize", required_argument, 0, 'm'}, | 1433 | {"pagesize", required_argument, 0, 'm'}, |
1432 | {"invert-regex", no_argument, NULL, INVERT_REGEX}, | 1434 | {"invert-regex", no_argument, NULL, INVERT_REGEX}, |
1435 | {"state-regex", required_argument, 0, STATE_REGEX}, | ||
1433 | {"use-ipv4", no_argument, 0, '4'}, | 1436 | {"use-ipv4", no_argument, 0, '4'}, |
1434 | {"use-ipv6", no_argument, 0, '6'}, | 1437 | {"use-ipv6", no_argument, 0, '6'}, |
1435 | {"extended-perfdata", no_argument, 0, 'E'}, | 1438 | {"extended-perfdata", no_argument, 0, 'E'}, |
@@ -1765,6 +1768,13 @@ process_arguments (int argc, char **argv) | |||
1765 | case INVERT_REGEX: | 1768 | case INVERT_REGEX: |
1766 | invert_regex = true; | 1769 | invert_regex = true; |
1767 | break; | 1770 | break; |
1771 | case STATE_REGEX: | ||
1772 | if (!strcmp (optarg, "critical")) | ||
1773 | state_regex = STATE_CRITICAL; | ||
1774 | else if (!strcmp (optarg, "warning")) | ||
1775 | state_regex = STATE_WARNING; | ||
1776 | else usage2 (_("Invalid state-regex option"), optarg); | ||
1777 | break; | ||
1768 | case '4': | 1778 | case '4': |
1769 | address_family = AF_INET; | 1779 | address_family = AF_INET; |
1770 | break; | 1780 | break; |
@@ -2040,7 +2050,10 @@ print_help (void) | |||
2040 | printf (" %s\n", "-R, --eregi=STRING"); | 2050 | printf (" %s\n", "-R, --eregi=STRING"); |
2041 | printf (" %s\n", _("Search page for case-insensitive regex STRING")); | 2051 | printf (" %s\n", _("Search page for case-insensitive regex STRING")); |
2042 | printf (" %s\n", "--invert-regex"); | 2052 | printf (" %s\n", "--invert-regex"); |
2043 | printf (" %s\n", _("Return CRITICAL if found, OK if not\n")); | 2053 | printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)")); |
2054 | printf (" %s\n", _("can be changed with --state--regex)")); | ||
2055 | printf (" %s\n", "--regex-state=STATE"); | ||
2056 | printf (" %s\n", _("Return STATE if regex is found, OK if not\n")); | ||
2044 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); | 2057 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); |
2045 | printf (" %s\n", _("Username:password on sites with basic authentication")); | 2058 | printf (" %s\n", _("Username:password on sites with basic authentication")); |
2046 | printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); | 2059 | printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); |