exist status is now correct

This commit is contained in:
Marius Pana 2015-02-04 17:28:07 +02:00
parent 1cc8165960
commit d26aeed784

View File

@ -17,7 +17,7 @@ nsargscount = len(nsargs)
try: try:
whois = pythonwhois.get_whois(args.domain[0]) whois = pythonwhois.get_whois(args.domain[0])
whoiscount = [] whoiscount = []
for key, value in whois.iteritems(): for key, value in whois.iteritems():
if key == "nameservers": if key == "nameservers":
whoiscount.append(value) whoiscount.append(value)
@ -27,13 +27,17 @@ except:
# how many nameservers did whois return? # how many nameservers did whois return?
#whoiscount = reduce(lambda x,y: x.extend(y),whoiscount) #whoiscount = reduce(lambda x,y: x.extend(y),whoiscount)
#print whoiscount #print len(whoiscount)
#print nsargscount
nscount = list(itertools.chain.from_iterable(whoiscount)) nscount = list(itertools.chain.from_iterable(whoiscount))
# print len(nscount) #print len(nscount)
if len(nscount) < nsargscount: 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: 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: else:
print("0 Extended_DNS_Check OK - all DNS server match") print("Extended_DNS_Check OK - all DNS server match")
sys.exit(0)