diff options
author | waja <waja@users.noreply.github.com> | 2024-07-23 19:24:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 19:24:45 (GMT) |
commit | 1cca389751c78cc5f86da80f942caaf6f6385bbd (patch) | |
tree | d0406ecb6d12955fec2a354ed27a23aab490692d /plugins/check_curl.c | |
parent | ea104fa400acfa017e9d7690dea19edef787421f (diff) | |
parent | 562deb749af3943dfcb6582ffcf48afb0b27e074 (diff) | |
download | monitoring-plugins-1cca389751c78cc5f86da80f942caaf6f6385bbd.tar.gz |
Merge pull request #2006 from monitoring-plugins/check_curl_features
Small check_curl fixes
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r-- | plugins/check_curl.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index fbb197f..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; |
@@ -2022,7 +2032,7 @@ print_help (void) | |||
2022 | printf (" %s\n", "-u, --url=PATH"); | 2032 | printf (" %s\n", "-u, --url=PATH"); |
2023 | printf (" %s\n", _("URL to GET or POST (default: /)")); | 2033 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
2024 | printf (" %s\n", "-P, --post=STRING"); | 2034 | printf (" %s\n", "-P, --post=STRING"); |
2025 | printf (" %s\n", _("URL encoded http POST data")); | 2035 | printf (" %s\n", _("URL decoded http POST data")); |
2026 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)"); | 2036 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT)"); |
2027 | printf (" %s\n", _("Set HTTP method.")); | 2037 | printf (" %s\n", _("Set HTTP method.")); |
2028 | printf (" %s\n", "-N, --no-body"); | 2038 | printf (" %s\n", "-N, --no-body"); |
@@ -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"); |