diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_dig.c | 9 | ||||
| -rw-r--r-- | plugins/t/check_dns.t | 12 |
2 files changed, 17 insertions, 4 deletions
diff --git a/plugins/check_dig.c b/plugins/check_dig.c index d9481f2d..d899b119 100644 --- a/plugins/check_dig.c +++ b/plugins/check_dig.c | |||
| @@ -94,8 +94,8 @@ main (int argc, char **argv) | |||
| 94 | timeout_interval_dig = timeout_interval / number_tries + number_tries; | 94 | timeout_interval_dig = timeout_interval / number_tries + number_tries; |
| 95 | 95 | ||
| 96 | /* get the command to run */ | 96 | /* get the command to run */ |
| 97 | xasprintf (&command_line, "%s @%s -p %d %s -t %s %s %s +tries=%d +time=%d", | 97 | xasprintf (&command_line, "%s %s %s -p %d @%s %s %s +tries=%d +time=%d", |
| 98 | PATH_TO_DIG, dns_server, server_port, query_address, record_type, dig_args, query_transport, number_tries, timeout_interval_dig); | 98 | PATH_TO_DIG, dig_args, query_transport, server_port, dns_server, query_address, record_type, number_tries, timeout_interval_dig); |
| 99 | 99 | ||
| 100 | alarm (timeout_interval); | 100 | alarm (timeout_interval); |
| 101 | gettimeofday (&tv, NULL); | 101 | gettimeofday (&tv, NULL); |
| @@ -296,7 +296,10 @@ process_arguments (int argc, char **argv) | |||
| 296 | dns_server = argv[c]; | 296 | dns_server = argv[c]; |
| 297 | } | 297 | } |
| 298 | else { | 298 | else { |
| 299 | dns_server = strdup ("127.0.0.1"); | 299 | if (strcmp(query_transport,"-6") == 0) |
| 300 | dns_server = strdup("::1"); | ||
| 301 | else | ||
| 302 | dns_server = strdup ("127.0.0.1"); | ||
| 300 | } | 303 | } |
| 301 | } | 304 | } |
| 302 | 305 | ||
diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t index b8858807..035e7682 100644 --- a/plugins/t/check_dns.t +++ b/plugins/t/check_dns.t | |||
| @@ -10,7 +10,7 @@ use NPTest; | |||
| 10 | 10 | ||
| 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); | 11 | plan skip_all => "check_dns not compiled" unless (-x "check_dns"); |
| 12 | 12 | ||
| 13 | plan tests => 14; | 13 | plan tests => 16; |
| 14 | 14 | ||
| 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; | 15 | my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/'; |
| 16 | 16 | ||
| @@ -43,6 +43,12 @@ my $dns_server = getTestParameter( | |||
| 43 | "A non default (remote) DNS server", | 43 | "A non default (remote) DNS server", |
| 44 | ); | 44 | ); |
| 45 | 45 | ||
| 46 | my $host_nonresponsive = getTestParameter( | ||
| 47 | "NP_HOST_NONRESPONSIVE", | ||
| 48 | "The hostname of system not responsive to network requests", | ||
| 49 | "10.0.0.1", | ||
| 50 | ); | ||
| 51 | |||
| 46 | my $res; | 52 | my $res; |
| 47 | 53 | ||
| 48 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5"); | 54 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5"); |
| @@ -66,6 +72,10 @@ like ( $res->output, $successOutput, "Output OK" ); | |||
| 66 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1"); | 72 | $res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1"); |
| 67 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server"); | 73 | cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server"); |
| 68 | 74 | ||
| 75 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -s $host_nonresponsive -t 2"); | ||
| 76 | cmp_ok( $res->return_code, '==', 2, "Got no answer from unresponsive server"); | ||
| 77 | like ( $res->output, "/CRITICAL - /", "Output OK"); | ||
| 78 | |||
| 69 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5"); | 79 | $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5"); |
| 70 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); | 80 | cmp_ok( $res->return_code, '==', 0, "Got expected address"); |
| 71 | 81 | ||
