diff options
author | Sven Nierlein <sven@nierlein.de> | 2017-05-28 21:10:20 +0200 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-22 16:30:31 +0200 |
commit | 7ad8bcba5bfc082a4e7b39a6ad908aa5d13de7d1 (patch) | |
tree | d41ae9141c64faaa73541335df0516c0cd92149a /plugins/check_curl.c | |
parent | 8172fe7f3052d32713b8c193429844cc243df47b (diff) | |
download | monitoring-plugins-7ad8bcba5bfc082a4e7b39a6ad908aa5d13de7d1.tar.gz |
check_curl: add proxy auth option
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r-- | plugins/check_curl.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c index 9d4c3f0b..15441959 100644 --- a/plugins/check_curl.c +++ b/plugins/check_curl.c | |||
@@ -175,6 +175,7 @@ char string_expect[MAX_INPUT_BUFFER] = ""; | |||
175 | char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; | 175 | char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; |
176 | int server_expect_yn = 0; | 176 | int server_expect_yn = 0; |
177 | char user_auth[MAX_INPUT_BUFFER] = ""; | 177 | char user_auth[MAX_INPUT_BUFFER] = ""; |
178 | char proxy_auth[MAX_INPUT_BUFFER] = ""; | ||
178 | char **http_opt_headers; | 179 | char **http_opt_headers; |
179 | int http_opt_headers_count = 0; | 180 | int http_opt_headers_count = 0; |
180 | int display_html = FALSE; | 181 | int display_html = FALSE; |
@@ -520,6 +521,10 @@ check_http (void) | |||
520 | /* set default or user-given user agent identification */ | 521 | /* set default or user-given user agent identification */ |
521 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERAGENT, user_agent), "CURLOPT_USERAGENT"); | 522 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERAGENT, user_agent), "CURLOPT_USERAGENT"); |
522 | 523 | ||
524 | /* proxy-authentication */ | ||
525 | if (strcmp(proxy_auth, "")) | ||
526 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXYUSERPWD, proxy_auth), "CURLOPT_PROXYUSERPWD"); | ||
527 | |||
523 | /* authentication */ | 528 | /* authentication */ |
524 | if (strcmp(user_auth, "")) | 529 | if (strcmp(user_auth, "")) |
525 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERPWD, user_auth), "CURLOPT_USERPWD"); | 530 | handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERPWD, user_auth), "CURLOPT_USERPWD"); |
@@ -1128,6 +1133,7 @@ process_arguments (int argc, char **argv) | |||
1128 | {"url", required_argument, 0, 'u'}, | 1133 | {"url", required_argument, 0, 'u'}, |
1129 | {"port", required_argument, 0, 'p'}, | 1134 | {"port", required_argument, 0, 'p'}, |
1130 | {"authorization", required_argument, 0, 'a'}, | 1135 | {"authorization", required_argument, 0, 'a'}, |
1136 | {"proxy-authorization", required_argument, 0, 'b'}, | ||
1131 | {"header-string", required_argument, 0, 'd'}, | 1137 | {"header-string", required_argument, 0, 'd'}, |
1132 | {"string", required_argument, 0, 's'}, | 1138 | {"string", required_argument, 0, 's'}, |
1133 | {"expect", required_argument, 0, 'e'}, | 1139 | {"expect", required_argument, 0, 'e'}, |
@@ -1171,7 +1177,7 @@ process_arguments (int argc, char **argv) | |||
1171 | } | 1177 | } |
1172 | 1178 | ||
1173 | while (1) { | 1179 | while (1) { |
1174 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option); | 1180 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:d:e:p:s:R:r:u:f:C:J:K:nlLS::m:M:NE", longopts, &option); |
1175 | if (c == -1 || c == EOF || c == 1) | 1181 | if (c == -1 || c == EOF || c == 1) |
1176 | break; | 1182 | break; |
1177 | 1183 | ||
@@ -1238,6 +1244,10 @@ process_arguments (int argc, char **argv) | |||
1238 | strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); | 1244 | strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); |
1239 | user_auth[MAX_INPUT_BUFFER - 1] = 0; | 1245 | user_auth[MAX_INPUT_BUFFER - 1] = 0; |
1240 | break; | 1246 | break; |
1247 | case 'b': /* proxy-authorization info */ | ||
1248 | strncpy (proxy_auth, optarg, MAX_INPUT_BUFFER - 1); | ||
1249 | proxy_auth[MAX_INPUT_BUFFER - 1] = 0; | ||
1250 | break; | ||
1241 | case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */ | 1251 | case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */ |
1242 | if (! http_post_data) | 1252 | if (! http_post_data) |
1243 | http_post_data = strdup (optarg); | 1253 | http_post_data = strdup (optarg); |
@@ -1648,6 +1658,8 @@ print_help (void) | |||
1648 | printf (" %s\n", _("Return CRITICAL if found, OK if not\n")); | 1658 | printf (" %s\n", _("Return CRITICAL if found, OK if not\n")); |
1649 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); | 1659 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); |
1650 | printf (" %s\n", _("Username:password on sites with basic authentication")); | 1660 | printf (" %s\n", _("Username:password on sites with basic authentication")); |
1661 | printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); | ||
1662 | printf (" %s\n", _("Username:password on proxy-servers with basic authentication")); | ||
1651 | printf (" %s\n", "-A, --useragent=STRING"); | 1663 | printf (" %s\n", "-A, --useragent=STRING"); |
1652 | printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); | 1664 | printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); |
1653 | printf (" %s\n", "-k, --header=STRING"); | 1665 | printf (" %s\n", "-k, --header=STRING"); |