ungleich-game/archive/check-cli.py

45 lines
1.2 KiB
Python
Raw Normal View History

2019-04-14 18:06:45 +00:00
#!/usr/bin/env python
import check
2019-04-14 18:30:04 +00:00
import argparse
import logging
2019-04-14 18:06:45 +00:00
2019-04-14 18:30:04 +00:00
logging.basicConfig()
log = logging.getLogger(None)
2019-04-14 18:06:45 +00:00
2019-04-14 18:30:04 +00:00
def do_checks():
checks = []
2019-04-14 18:06:45 +00:00
2019-04-14 18:30:04 +00:00
checks.append(check.DNSCheck("www.ungleich.ch"))
checks.append(check.DNSCheck("www.ungleich.ch", expected_result="2a0a:e5c0:0:2:400:b3ff:fe39:795c"))
checks.append(check.DNSCheck("www.ungleich.ch", rr_type="A", expected_result="185.203.112.17"))
2019-04-14 18:06:45 +00:00
2019-04-14 18:30:04 +00:00
for num_server in range(1,6):
server="d{}.ungleich.ch".format(num_server)
2019-04-14 18:06:45 +00:00
2019-04-14 18:30:04 +00:00
checks.append(check.DNSCheck("www.ungleich.ch", server=server))
checks.append(check.DFCheck(server))
for c in checks:
print("{} {}".format(c, c.check()))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='checks')
parser.add_argument('--debug', help='Enable debug logging', action='store_true')
parser.add_argument('--verbose', help='Enable verbose logging', action='store_true')
args = parser.parse_args()
if args.debug:
log.setLevel(logging.DEBUG)
print("dbg")
elif args.verbose:
log.setLevel(logging.INFO)
else:
log.setLevel(logging.WARNING)
do_checks()