diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/check_http.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 79f6adf..b4e6004 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -105,6 +105,7 @@ int check_warning_time = FALSE; | |||
105 | double critical_time = 0; | 105 | double critical_time = 0; |
106 | int check_critical_time = FALSE; | 106 | int check_critical_time = FALSE; |
107 | char user_auth[MAX_INPUT_BUFFER] = ""; | 107 | char user_auth[MAX_INPUT_BUFFER] = ""; |
108 | char proxy_auth[MAX_INPUT_BUFFER] = ""; | ||
108 | int display_html = FALSE; | 109 | int display_html = FALSE; |
109 | char **http_opt_headers; | 110 | char **http_opt_headers; |
110 | int http_opt_headers_count = 0; | 111 | int http_opt_headers_count = 0; |
@@ -192,6 +193,7 @@ process_arguments (int argc, char **argv) | |||
192 | {"url", required_argument, 0, 'u'}, | 193 | {"url", required_argument, 0, 'u'}, |
193 | {"port", required_argument, 0, 'p'}, | 194 | {"port", required_argument, 0, 'p'}, |
194 | {"authorization", required_argument, 0, 'a'}, | 195 | {"authorization", required_argument, 0, 'a'}, |
196 | {"proxy_authorization", required_argument, 0, 'b'}, | ||
195 | {"string", required_argument, 0, 's'}, | 197 | {"string", required_argument, 0, 's'}, |
196 | {"expect", required_argument, 0, 'e'}, | 198 | {"expect", required_argument, 0, 'e'}, |
197 | {"regex", required_argument, 0, 'r'}, | 199 | {"regex", required_argument, 0, 'r'}, |
@@ -229,7 +231,7 @@ process_arguments (int argc, char **argv) | |||
229 | } | 231 | } |
230 | 232 | ||
231 | while (1) { | 233 | while (1) { |
232 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); | 234 | c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:P:j:T:I:a:b:e:p:s:R:r:u:f:C:nlLSm:M:N", longopts, &option); |
233 | if (c == -1 || c == EOF) | 235 | if (c == -1 || c == EOF) |
234 | break; | 236 | break; |
235 | 237 | ||
@@ -350,6 +352,10 @@ process_arguments (int argc, char **argv) | |||
350 | strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); | 352 | strncpy (user_auth, optarg, MAX_INPUT_BUFFER - 1); |
351 | user_auth[MAX_INPUT_BUFFER - 1] = 0; | 353 | user_auth[MAX_INPUT_BUFFER - 1] = 0; |
352 | break; | 354 | break; |
355 | case 'b': /* proxy-authorization info */ | ||
356 | strncpy (proxy_auth, optarg, MAX_INPUT_BUFFER - 1); | ||
357 | proxy_auth[MAX_INPUT_BUFFER - 1] = 0; | ||
358 | break; | ||
353 | case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */ | 359 | case 'P': /* HTTP POST data in URL encoded format; ignored if settings already */ |
354 | if (! http_post_data) | 360 | if (! http_post_data) |
355 | http_post_data = strdup (optarg); | 361 | http_post_data = strdup (optarg); |
@@ -836,6 +842,12 @@ check_http (void) | |||
836 | asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); | 842 | asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); |
837 | } | 843 | } |
838 | 844 | ||
845 | /* optionally send the proxy authentication info */ | ||
846 | if (strlen(proxy_auth)) { | ||
847 | base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); | ||
848 | asprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); | ||
849 | } | ||
850 | |||
839 | /* either send http POST data (any data, not only POST)*/ | 851 | /* either send http POST data (any data, not only POST)*/ |
840 | if (http_post_data) { | 852 | if (http_post_data) { |
841 | if (http_content_type) { | 853 | if (http_content_type) { |
@@ -1346,6 +1358,8 @@ print_help (void) | |||
1346 | 1358 | ||
1347 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); | 1359 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); |
1348 | printf (" %s\n", _("Username:password on sites with basic authentication")); | 1360 | printf (" %s\n", _("Username:password on sites with basic authentication")); |
1361 | printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); | ||
1362 | printf (" %s\n", _("Username:password on proxy-servers with basic authentication")); | ||
1349 | printf (" %s\n", "-A, --useragent=STRING"); | 1363 | printf (" %s\n", "-A, --useragent=STRING"); |
1350 | printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); | 1364 | printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); |
1351 | printf (" %s\n", "-k, --header=STRING"); | 1365 | printf (" %s\n", "-k, --header=STRING"); |
@@ -1407,7 +1421,7 @@ print_usage (void) | |||
1407 | printf (_("Usage:")); | 1421 | printf (_("Usage:")); |
1408 | printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); | 1422 | printf (" %s -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]\n",progname); |
1409 | printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n"); | 1423 | printf (" [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n"); |
1410 | printf (" [-a auth] [-f <ok | warn | critcal | follow | sticky | stickyport>]\n"); | 1424 | printf (" [-a auth] [-b proxy_auth] [-f <ok | warn | critcal | follow | sticky | stickyport>]\n"); |
1411 | printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); | 1425 | printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); |
1412 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); | 1426 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); |
1413 | printf (" [-A string] [-k string] [-S] [-C <age>] [-T <content-type>] [-j method]\n"); | 1427 | printf (" [-A string] [-k string] [-S] [-C <age>] [-T <content-type>] [-j method]\n"); |