summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2022-01-29 10:11:36 (GMT)
committerSven Nierlein <sven@nierlein.org>2022-01-29 11:15:12 (GMT)
commit737412f7391ae430a51e8f2c2a3b1ab2d35a6394 (patch)
tree7cf7996e8a2fe227edab7fb8c6279fdf6d42424d /plugins/check_curl.c
parente2397167c7e5c7a02b68de45de946f63706e7d12 (diff)
downloadmonitoring-plugins-737412f7391ae430a51e8f2c2a3b1ab2d35a6394.tar.gz
check_http and check_curl: added --max-redirs=N option (feature #1684)
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 14cc846..32d919f 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -66,13 +66,13 @@ const char *email = "devel@monitoring-plugins.org";
66#define DEFAULT_BUFFER_SIZE 2048 66#define DEFAULT_BUFFER_SIZE 2048
67#define DEFAULT_SERVER_URL "/" 67#define DEFAULT_SERVER_URL "/"
68#define HTTP_EXPECT "HTTP/" 68#define HTTP_EXPECT "HTTP/"
69#define DEFAULT_MAX_REDIRS 15
70#define INET_ADDR_MAX_SIZE INET6_ADDRSTRLEN 69#define INET_ADDR_MAX_SIZE INET6_ADDRSTRLEN
71enum { 70enum {
72 MAX_IPV4_HOSTLENGTH = 255, 71 MAX_IPV4_HOSTLENGTH = 255,
73 HTTP_PORT = 80, 72 HTTP_PORT = 80,
74 HTTPS_PORT = 443, 73 HTTPS_PORT = 443,
75 MAX_PORT = 65535 74 MAX_PORT = 65535,
75 DEFAULT_MAX_REDIRS = 15
76}; 76};
77 77
78enum { 78enum {
@@ -1210,6 +1210,7 @@ process_arguments (int argc, char **argv)
1210 enum { 1210 enum {
1211 INVERT_REGEX = CHAR_MAX + 1, 1211 INVERT_REGEX = CHAR_MAX + 1,
1212 SNI_OPTION, 1212 SNI_OPTION,
1213 MAX_REDIRS_OPTION,
1213 CA_CERT_OPTION, 1214 CA_CERT_OPTION,
1214 HTTP_VERSION_OPTION, 1215 HTTP_VERSION_OPTION,
1215 AUTOMATIC_DECOMPRESSION 1216 AUTOMATIC_DECOMPRESSION
@@ -1254,6 +1255,7 @@ process_arguments (int argc, char **argv)
1254 {"use-ipv6", no_argument, 0, '6'}, 1255 {"use-ipv6", no_argument, 0, '6'},
1255 {"extended-perfdata", no_argument, 0, 'E'}, 1256 {"extended-perfdata", no_argument, 0, 'E'},
1256 {"show-body", no_argument, 0, 'B'}, 1257 {"show-body", no_argument, 0, 'B'},
1258 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION},
1257 {"http-version", required_argument, 0, HTTP_VERSION_OPTION}, 1259 {"http-version", required_argument, 0, HTTP_VERSION_OPTION},
1258 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION}, 1260 {"enable-automatic-decompression", no_argument, 0, AUTOMATIC_DECOMPRESSION},
1259 {0, 0, 0, 0} 1261 {0, 0, 0, 0}
@@ -1512,6 +1514,13 @@ process_arguments (int argc, char **argv)
1512 use_sni = TRUE; 1514 use_sni = TRUE;
1513 break; 1515 break;
1514#endif /* LIBCURL_FEATURE_SSL */ 1516#endif /* LIBCURL_FEATURE_SSL */
1517 case MAX_REDIRS_OPTION:
1518 if (!is_intnonneg (optarg))
1519 usage2 (_("Invalid max_redirs count"), optarg);
1520 else {
1521 max_depth = atoi (optarg);
1522 }
1523 break;
1515 case 'f': /* onredirect */ 1524 case 'f': /* onredirect */
1516 if (!strcmp (optarg, "ok")) 1525 if (!strcmp (optarg, "ok"))
1517 onredirect = STATE_OK; 1526 onredirect = STATE_OK;
@@ -1854,6 +1863,9 @@ print_help (void)
1854 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same.")); 1863 printf (" %s\n", _("specified IP address. stickyport also ensures port stays the same."));
1855 printf (" %s\n", _("follow uses the old redirection algorithm of check_http.")); 1864 printf (" %s\n", _("follow uses the old redirection algorithm of check_http."));
1856 printf (" %s\n", _("curl uses CURL_FOLLOWLOCATION built into libcurl.")); 1865 printf (" %s\n", _("curl uses CURL_FOLLOWLOCATION built into libcurl."));
1866 printf (" %s\n", "--max-redirs=INTEGER");
1867 printf (" %s", _("Maximal number of redirects (default: "));
1868 printf ("%d)\n", DEFAULT_MAX_REDIRS);
1857 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); 1869 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
1858 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); 1870 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));
1859 printf ("\n"); 1871 printf ("\n");