something that works
This commit is contained in:
parent
44e63b7891
commit
1cc8165960
31
check_extended_dns.py
Executable file → Normal file
31
check_extended_dns.py
Executable file → Normal file
@ -3,16 +3,37 @@
|
||||
import pythonwhois
|
||||
import argparse
|
||||
import sys
|
||||
import itertools
|
||||
|
||||
parser = argparse.ArgumentParser(description='Check whois and dns information.')
|
||||
parser.add_argument('--domain', nargs=1, required=True, help='the domain name')
|
||||
parser.add_argument('--nameserver', nargs='*', help='a space delimited list of nameservers')
|
||||
|
||||
parser.add_argument('--nameserver', nargs='+', help='a space delimited list of nameservers')
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
domain = pythonwhois.get_whois(args.domain[0])
|
||||
nsargs = args.nameserver
|
||||
# how many ns servers should we expect?
|
||||
nsargscount = len(nsargs)
|
||||
|
||||
try:
|
||||
whois = pythonwhois.get_whois(args.domain[0])
|
||||
whoiscount = []
|
||||
|
||||
for key, value in whois.iteritems():
|
||||
if key == "nameservers":
|
||||
whoiscount.append(value)
|
||||
except:
|
||||
#something happened, raise an erro
|
||||
print "3 Unexpected error: ", sys.exc_info()[0]
|
||||
print "3 Unexpected_error: ", sys.exc_info()[0]
|
||||
|
||||
# how many nameservers did whois return?
|
||||
#whoiscount = reduce(lambda x,y: x.extend(y),whoiscount)
|
||||
#print whoiscount
|
||||
nscount = list(itertools.chain.from_iterable(whoiscount))
|
||||
# print len(nscount)
|
||||
|
||||
if len(nscount) < nsargscount:
|
||||
print("2 Extended_DNS_Check CRITICAL - WHOIS DNS servers do not match provided DNS nameservers.")
|
||||
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.")
|
||||
else:
|
||||
print("0 Extended_DNS_Check OK - all DNS server match")
|
Loading…
Reference in New Issue
Block a user