summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-03-17 18:51:57 (GMT)
committerSven Nierlein <sven@nierlein.de>2018-10-22 14:28:51 (GMT)
commitdee8f760d3c9935a52b1d49b63940f35b3656dc8 (patch)
treeda09ab4e32242f3050eb6efc3f6228f4548fa8a3
parenta478dfe512e08bbba95fca1b4059a9591bec86ab (diff)
downloadmonitoring-plugins-dee8f760d3c9935a52b1d49b63940f35b3656dc8.tar.gz
added -4/-6 option
-rw-r--r--plugins/check_curl.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index 49b430c..3d368c1 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -133,6 +133,7 @@ char *client_privkey = NULL;
133char *ca_cert = NULL; 133char *ca_cert = NULL;
134X509 *cert = NULL; 134X509 *cert = NULL;
135int no_body = FALSE; 135int no_body = FALSE;
136int address_family = AF_UNSPEC;
136 137
137int process_arguments (int, char**); 138int process_arguments (int, char**);
138int check_http (void); 139int check_http (void);
@@ -332,6 +333,14 @@ check_http (void)
332 if (no_body) 333 if (no_body)
333 curl_easy_setopt (curl, CURLOPT_NOBODY, 1); 334 curl_easy_setopt (curl, CURLOPT_NOBODY, 1);
334 335
336 /* IPv4 or IPv6 forced DNS resolution */
337 if (address_family == AF_UNSPEC)
338 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
339 else if (address_family == AF_INET)
340 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
341 else if (address_family == AF_INET6)
342 curl_easy_setopt (curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
343
335 /* do the request */ 344 /* do the request */
336 res = curl_easy_perform(curl); 345 res = curl_easy_perform(curl);
337 346
@@ -548,6 +557,8 @@ process_arguments (int argc, char **argv)
548 {"no-body", no_argument, 0, 'N'}, 557 {"no-body", no_argument, 0, 'N'},
549 {"pagesize", required_argument, 0, 'm'}, 558 {"pagesize", required_argument, 0, 'm'},
550 {"invert-regex", no_argument, NULL, INVERT_REGEX}, 559 {"invert-regex", no_argument, NULL, INVERT_REGEX},
560 {"use-ipv4", no_argument, 0, '4'},
561 {"use-ipv6", no_argument, 0, '6'},
551 {"extended-perfdata", no_argument, 0, 'E'}, 562 {"extended-perfdata", no_argument, 0, 'E'},
552 {0, 0, 0, 0} 563 {0, 0, 0, 0}
553 }; 564 };
@@ -556,7 +567,7 @@ process_arguments (int argc, char **argv)
556 return ERROR; 567 return ERROR;
557 568
558 while (1) { 569 while (1) {
559 c = getopt_long (argc, argv, "Vvht:c:w:A:k:H:j:I:a:p:s:R:r:u:f:C:J:K:S::m:NE", longopts, &option); 570 c = getopt_long (argc, argv, "Vvh46t:c:w:A:k:H:j:I:a:p:s:R:r:u:f:C:J:K:S::m:NE", longopts, &option);
560 if (c == -1 || c == EOF || c == 1) 571 if (c == -1 || c == EOF || c == 1)
561 break; 572 break;
562 573
@@ -741,6 +752,16 @@ process_arguments (int argc, char **argv)
741 case INVERT_REGEX: 752 case INVERT_REGEX:
742 invert_regex = 1; 753 invert_regex = 1;
743 break; 754 break;
755 case '4':
756 address_family = AF_INET;
757 break;
758 case '6':
759#ifdef USE_IPV6
760 address_family = AF_INET6;
761#else
762 usage4 (_("IPv6 support not available"));
763#endif
764 break;
744 case 'm': /* min_page_length */ 765 case 'm': /* min_page_length */
745 { 766 {
746 char *tmp; 767 char *tmp;
@@ -847,6 +868,8 @@ print_help (void)
847 printf (" %s", _("Port number (default: ")); 868 printf (" %s", _("Port number (default: "));
848 printf ("%d)\n", HTTP_PORT); 869 printf ("%d)\n", HTTP_PORT);
849 870
871 printf (UT_IPv46);
872
850#ifdef LIBCURL_FEATURE_SSL 873#ifdef LIBCURL_FEATURE_SSL
851 printf (" %s\n", "-S, --ssl=VERSION[+]"); 874 printf (" %s\n", "-S, --ssl=VERSION[+]");
852 printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents")); 875 printf (" %s\n", _("Connect via SSL. Port defaults to 443. VERSION is optional, and prevents"));
@@ -970,7 +993,7 @@ print_usage (void)
970 printf (" [-f <ok|warning|critcal|follow>]\n"); 993 printf (" [-f <ok|warning|critcal|follow>]\n");
971 printf (" [-s string] [-r <regex> | -R <case-insensitive regex>]\n"); 994 printf (" [-s string] [-r <regex> | -R <case-insensitive regex>]\n");
972 printf (" [-m <min_pg_size>:<max_pg_size>] [-N]\n"); 995 printf (" [-m <min_pg_size>:<max_pg_size>] [-N]\n");
973 printf (" [-N]\n"); 996 printf (" [-4|-6] [-N]\n");
974 printf (" [-A string] [-k string] [-S <version>] [-C]\n"); 997 printf (" [-A string] [-k string] [-S <version>] [-C]\n");
975 printf (" [-v verbose]\n", progname); 998 printf (" [-v verbose]\n", progname);
976 printf ("\n"); 999 printf ("\n");