From 22b0bc005721fdc5727ea8a441ad12f9a6fe8912 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Thu, 22 Jun 2023 16:31:54 -0600 Subject: [PATCH] check_dns_tls: use ms --- check_dns_tls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check_dns_tls.py b/check_dns_tls.py index e7d0e65..5bd997b 100755 --- a/check_dns_tls.py +++ b/check_dns_tls.py @@ -16,8 +16,8 @@ def resolve_dns_server_ip(server): def main(): 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('-w', '--warning', type=float, default=0.3, help='Warning threshold for response time in seconds (default: 0.3)') + 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=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('-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)') @@ -54,12 +54,12 @@ def main(): sys.exit(2) 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.') 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.') sys.exit(1) else: