From d26aeed78496853067b5837e021659f313e18b05 Mon Sep 17 00:00:00 2001 From: Marius Pana <mp@sphs.ro> Date: Wed, 4 Feb 2015 17:28:07 +0200 Subject: [PATCH] exist status is now correct --- check_extended_dns.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/check_extended_dns.py b/check_extended_dns.py index 4f6d3f0..e35f996 100644 --- a/check_extended_dns.py +++ b/check_extended_dns.py @@ -17,7 +17,7 @@ nsargscount = len(nsargs) try: whois = pythonwhois.get_whois(args.domain[0]) whoiscount = [] - + for key, value in whois.iteritems(): if key == "nameservers": whoiscount.append(value) @@ -27,13 +27,17 @@ except: # how many nameservers did whois return? #whoiscount = reduce(lambda x,y: x.extend(y),whoiscount) -#print whoiscount +#print len(whoiscount) +#print nsargscount nscount = list(itertools.chain.from_iterable(whoiscount)) -# print len(nscount) +#print len(nscount) if len(nscount) < nsargscount: - print("2 Extended_DNS_Check CRITICAL - WHOIS DNS servers do not match provided DNS nameservers.") + print("Extended_DNS_Check CRITICAL - WHOIS DNS servers do not match provided DNS nameservers.") + sys.exit(2) elif len(nscount) > nsargscount: - print("1 Extended_DNS_Check WARNING - WHOIS DNS servers do not match. There are more DNS servers from the WHOIS datbase than in your query.") + print("Extended_DNS_Check WARNING - WHOIS DNS servers do not match. There are more DNS servers from the WHOIS datbase than in your query.") + sys.exit(1) else: - print("0 Extended_DNS_Check OK - all DNS server match") \ No newline at end of file + print("Extended_DNS_Check OK - all DNS server match") + sys.exit(0)