[monitoring-plugins] check_dns: added test for nonresponsive dns ...

Sven Nierlein git at monitoring-plugins.org
Wed Jul 30 12:00:07 CEST 2014


 Module: monitoring-plugins
 Branch: master
 Commit: 2acf9a63d357d7309dc26511fa58a4cf23a449b1
 Author: Sven Nierlein <sven at nierlein.de>
   Date: Wed Jul 30 11:49:50 2014 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=2acf9a6

check_dns: added test for nonresponsive dns server (#982)

Signed-off-by: Sven Nierlein <sven at nierlein.de>

---

 plugins/t/check_dns.t | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/plugins/t/check_dns.t b/plugins/t/check_dns.t
index b885880..035e768 100644
--- a/plugins/t/check_dns.t
+++ b/plugins/t/check_dns.t
@@ -10,7 +10,7 @@ use NPTest;
 
 plan skip_all => "check_dns not compiled" unless (-x "check_dns");
 
-plan tests => 14;
+plan tests => 16;
 
 my $successOutput = '/DNS OK: [\.0-9]+ seconds? response time/';
 
@@ -43,6 +43,12 @@ my $dns_server       = getTestParameter(
 			"A non default (remote) DNS server",
 			);
 
+my $host_nonresponsive = getTestParameter(
+			"NP_HOST_NONRESPONSIVE",
+			"The hostname of system not responsive to network requests",
+			"10.0.0.1",
+			);
+
 my $res;
 
 $res = NPTest->testCmd("./check_dns -H $hostname_valid -t 5");
@@ -66,6 +72,10 @@ like  ( $res->output, $successOutput, "Output OK" );
 $res = NPTest->testCmd("./check_dns -H $hostname_invalid -s $dns_server -t 1");
 cmp_ok( $res->return_code, '==', 2, "Invalid $hostname_invalid on $dns_server");
 
+$res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -s $host_nonresponsive -t 2");
+cmp_ok( $res->return_code, '==', 2, "Got no answer from unresponsive server");
+like  ( $res->output, "/CRITICAL - /", "Output OK");
+
 $res = NPTest->testCmd("./check_dns -H $hostname_valid -a $hostname_valid_ip -t 5");
 cmp_ok( $res->return_code, '==', 0, "Got expected address");
 



More information about the Commits mailing list