check_dns_tls: use ms
This commit is contained in:
parent
8f99c858ec
commit
22b0bc0057
|
@ -16,8 +16,8 @@ def resolve_dns_server_ip(server):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='Check DNS-over-TLS connectivity and response time')
|
parser = argparse.ArgumentParser(description='Check DNS-over-TLS connectivity and response time')
|
||||||
parser.add_argument('-c', '--critical', type=float, default=0.5, help='Critical threshold for response time in seconds (default: 0.5)')
|
parser.add_argument('-c', '--critical', type=float, default=500, help='Critical threshold for response time in milliseconds (default: 500)')
|
||||||
parser.add_argument('-w', '--warning', type=float, default=0.3, help='Warning threshold for response time in seconds (default: 0.3)')
|
parser.add_argument('-w', '--warning', type=float, default=300, help='Warning threshold for response time in milliseconds (default: 300)')
|
||||||
parser.add_argument('-d', '--domain', type=str, default='google.com', help='Domain to resolve (default: google.com)')
|
parser.add_argument('-d', '--domain', type=str, default='google.com', help='Domain to resolve (default: google.com)')
|
||||||
parser.add_argument('-s', '--server', type=str, required=True, help='DNS server address')
|
parser.add_argument('-s', '--server', type=str, required=True, help='DNS server address')
|
||||||
parser.add_argument('-p', '--port', type=int, default=853, help='Port to use for DNS-over-TLS (default: 853)')
|
parser.add_argument('-p', '--port', type=int, default=853, help='Port to use for DNS-over-TLS (default: 853)')
|
||||||
|
@ -54,12 +54,12 @@ def main():
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
resolved_ips = [str(rr.address) for rr in response.answer[0] if rr.rdtype == dns.rdatatype.A]
|
resolved_ips = [str(rr.address) for rr in response.answer[0] if rr.rdtype == dns.rdatatype.A]
|
||||||
perfdata = f'Resolved IPs: {", ".join(resolved_ips)} | response_time={response_time_ms}ms;{int(args.warning * 1000)};{int(args.critical * 1000)};0;'
|
perfdata = f'Resolved IPs: {", ".join(resolved_ips)} | response_time={response_time_ms}ms;{args.warning};{args.critical};0;'
|
||||||
|
|
||||||
if response_time >= args.critical:
|
if response_time_ms >= args.critical:
|
||||||
print(f'CRITICAL - DNS-over-TLS response time: {response_time:.2f} sec.')
|
print(f'CRITICAL - DNS-over-TLS response time: {response_time:.2f} sec.')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
elif response_time >= args.warning:
|
elif response_time_ms >= args.warning:
|
||||||
print(f'WARNING - DNS-over-TLS response time: {response_time:.2f} sec.')
|
print(f'WARNING - DNS-over-TLS response time: {response_time:.2f} sec.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue