diff options
| author | Ville Mattila <vmattila@csc.fi> | 2012-12-28 12:17:15 +0200 |
|---|---|---|
| committer | Sven Nierlein <sven@nierlein.de> | 2013-01-23 20:04:04 +0100 |
| commit | 261ad186706422af00ec7e67dc128a99c4603b8c (patch) | |
| tree | 32067ee9d209d33a3f1431434d75d4e6d8328d1a | |
| parent | 8d63b171b0c3e909f237dc244c1bbe8d7b5104c8 (diff) | |
| download | monitoring-plugins-261ad186706422af00ec7e67dc128a99c4603b8c.tar.gz | |
check_dig: query transport selection support
Add command line options -4 and -6 (--use-ipv4 and
--use-ipv6) to check_dig.
Effectively this adds no new functionality, just a
shortcut for:
check_dig -A "-4"
check_dig -A "-6"
Needed for using check_dig with the check_v46 wrapper
(see e.g.
https://gitorious.org/nagios-monitoring-tools/nagios-monitoring-tools/blobs/master/check_v46)
which requires -4/-6 command line option support.
| -rw-r--r-- | plugins/check_dig.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index 893e0a14..3c80cb72 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
| @@ -54,6 +54,7 @@ char *record_type = "A"; | |||
| 54 | char *expected_address = NULL; | 54 | char *expected_address = NULL; |
| 55 | char *dns_server = NULL; | 55 | char *dns_server = NULL; |
| 56 | char *dig_args = ""; | 56 | char *dig_args = ""; |
| 57 | char *query_transport = ""; | ||
| 57 | int verbose = FALSE; | 58 | int verbose = FALSE; |
| 58 | int server_port = DEFAULT_PORT; | 59 | int server_port = DEFAULT_PORT; |
| 59 | double warning_interval = UNDEFINED; | 60 | double warning_interval = UNDEFINED; |
| @@ -87,8 +88,8 @@ main (int argc, char **argv) | |||
| 87 | usage_va(_("Could not parse arguments")); | 88 | usage_va(_("Could not parse arguments")); |
| 88 | 89 | ||
| 89 | /* get the command to run */ | 90 | /* get the command to run */ |
| 90 | xasprintf (&command_line, "%s @%s -p %d %s -t %s %s", | 91 | xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s", |
| 91 | PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args); | 92 | PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport); |
| 92 | 93 | ||
| 93 | alarm (timeout_interval); | 94 | alarm (timeout_interval); |
| 94 | gettimeofday (&tv, NULL); | 95 | gettimeofday (&tv, NULL); |
| @@ -199,6 +200,8 @@ process_arguments (int argc, char **argv) | |||
| 199 | {"record_type", required_argument, 0, 'T'}, | 200 | {"record_type", required_argument, 0, 'T'}, |
| 200 | {"expected_address", required_argument, 0, 'a'}, | 201 | {"expected_address", required_argument, 0, 'a'}, |
| 201 | {"port", required_argument, 0, 'p'}, | 202 | {"port", required_argument, 0, 'p'}, |
| 203 | {"use-ipv4", no_argument, 0, '4'}, | ||
| 204 | {"use-ipv6", no_argument, 0, '6'}, | ||
| 202 | {0, 0, 0, 0} | 205 | {0, 0, 0, 0} |
| 203 | }; | 206 | }; |
| 204 | 207 | ||
| @@ -206,7 +209,7 @@ process_arguments (int argc, char **argv) | |||
| 206 | return ERROR; | 209 | return ERROR; |
| 207 | 210 | ||
| 208 | while (1) { | 211 | while (1) { |
| 209 | c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:p:a:A:", longopts, &option); | 212 | c = getopt_long (argc, argv, "hVvt:l:H:w:c:T:p:a:A:46", longopts, &option); |
| 210 | 213 | ||
| 211 | if (c == -1 || c == EOF) | 214 | if (c == -1 || c == EOF) |
| 212 | break; | 215 | break; |
| @@ -269,6 +272,12 @@ process_arguments (int argc, char **argv) | |||
| 269 | case 'a': | 272 | case 'a': |
| 270 | expected_address = optarg; | 273 | expected_address = optarg; |
| 271 | break; | 274 | break; |
| 275 | case '4': | ||
| 276 | query_transport = "-4"; | ||
| 277 | break; | ||
| 278 | case '6': | ||
| 279 | query_transport = "-6"; | ||
| 280 | break; | ||
| 272 | default: /* usage5 */ | 281 | default: /* usage5 */ |
| 273 | usage5(); | 282 | usage5(); |
| 274 | } | 283 | } |
| @@ -325,6 +334,10 @@ print_help (void) | |||
| 325 | 334 | ||
| 326 | printf (UT_HOST_PORT, 'p', myport); | 335 | printf (UT_HOST_PORT, 'p', myport); |
| 327 | 336 | ||
| 337 | printf (" %s\n","-4, --use-ipv4"); | ||
| 338 | printf (" %s\n",_("Force dig to only use IPv4 query transport")); | ||
| 339 | printf (" %s\n","-6, --use-ipv6"); | ||
| 340 | printf (" %s\n",_("Force dig to only use IPv6 query transport")); | ||
| 328 | printf (" %s\n","-l, --query_address=STRING"); | 341 | printf (" %s\n","-l, --query_address=STRING"); |
| 329 | printf (" %s\n",_("Machine name to lookup")); | 342 | printf (" %s\n",_("Machine name to lookup")); |
| 330 | printf (" %s\n","-T, --record_type=STRING"); | 343 | printf (" %s\n","-T, --record_type=STRING"); |
