exist status is now correct

This commit is contained in:
Marius Pana 2015-02-04 17:28:07 +02:00
parent 1cc8165960
commit d26aeed784
1 changed files with 10 additions and 6 deletions

View File

@ -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")
print("Extended_DNS_Check OK - all DNS server match")
sys.exit(0)