aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.de> 2017-05-28 21:10:20 +0200
committerGravatar Sven Nierlein <sven@nierlein.de> 2018-10-22 16:30:31 +0200
commit7ad8bcba5bfc082a4e7b39a6ad908aa5d13de7d1 (patch)
treed41ae9141c64faaa73541335df0516c0cd92149a
parent8172fe7f3052d32713b8c193429844cc243df47b (diff)
downloadmonitoring-plugins-7ad8bcba5bfc082a4e7b39a6ad908aa5d13de7d1.tar.gz
check_curl: add proxy auth option
-rw-r--r--plugins/check_curl.c14
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] = "";
char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
int server_expect_yn = 0;
char user_auth[MAX_INPUT_BUFFER] = "";
+char proxy_auth[MAX_INPUT_BUFFER] = "";
char **http_opt_headers;
int http_opt_headers_count = 0;
int display_html = FALSE;
@@ -520,6 +521,10 @@ check_http (void)
/* set default or user-given user agent identification */
handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_USERAGENT, user_agent), "CURLOPT_USERAGENT");
+ /* proxy-authentication */
+ if (strcmp(proxy_auth, ""))
+ handle_curl_option_return_code (curl_easy_setopt (curl, CURLOPT_PROXYUSERPWD, proxy_auth), "CURLOPT_PROXYUSERPWD");
+
/* authentication */
if (strcmp(user_auth, ""))
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)
{"url", required_argument, 0, 'u'},
{"port", required_argument, 0, 'p'},
{"authorization", required_argument, 0, 'a'},
+ {"proxy-authorization", required_argument, 0, 'b'},
{"header-string", required_argument, 0, 'd'},
{"string", required_argument, 0, 's'},
{"expect", required_argument, 0, 'e'},
@@ -1171,7 +1177,7 @@ process_arguments (int argc, char **argv)
}
while (1) {
- 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);
+ 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);
if (c == -1 || c == EOF || c == 1)
break;
@@ -1238,6 +1244,10 @@ process_arguments (int argc, char **argv)
strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1);
user_auth[MAX_INPUT_BUFFER - 1] = 0;
break;
+ case 'b': /* proxy-authorization info */
+ strncpy (proxy_auth, optarg, MAX_INPUT_BUFFER - 1);
+ proxy_auth[MAX_INPUT_BUFFER - 1] = 0;
+ break;
case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */
if (! http_post_data)
http_post_data = strdup (optarg);
@@ -1648,6 +1658,8 @@ print_help (void)
printf (" %s\n", _("Return CRITICAL if found, OK if not\n"));
printf (" %s\n", "-a, --authorization=AUTH_PAIR");
printf (" %s\n", _("Username:password on sites with basic authentication"));
+ printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
+ printf (" %s\n", _("Username:password on proxy-servers with basic authentication"));
printf (" %s\n", "-A, --useragent=STRING");
printf (" %s\n", _("String to be sent in http header as \"User Agent\""));
printf (" %s\n", "-k, --header=STRING");