summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-03-17 19:51:57 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2017-03-17 19:51:57 +0100
commit7360d2f06a44a7527a16c7a5ad32c55356cbec9d (patch)
treef9a16866aa93a7dc5d42011c3664d3454923ee63 /plugins
parent470a68b9c08f02e3330fc3e45cb5c58b69367cff (diff)
downloadmonitoring-plugins-7360d2f.tar.gz
added -4/-6 option
Diffstat (limited to 'plugins')
-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 49b430c0..3d368c16 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");