From 3f139c41657ac648f40939b63066075bfb87775b Mon Sep 17 00:00:00 2001 From: Adrian Moisey Date: Mon, 21 Jul 2025 21:37:09 +0200 Subject: [PATCH 1/2] Add DNS lookup plugin --- config/network-problem-monitor.json | 6 ++++++ config/plugin/dns_problem.sh | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 config/plugin/dns_problem.sh diff --git a/config/network-problem-monitor.json b/config/network-problem-monitor.json index 7a4c48bf..6b13f436 100644 --- a/config/network-problem-monitor.json +++ b/config/network-problem-monitor.json @@ -15,6 +15,12 @@ "reason": "ConntrackFull", "path": "./config/plugin/network_problem.sh", "timeout": "3s" + }, + { + "type": "temporary", + "reason": "DNSUnreachable", + "path": "./config/plugin/dns_problem.sh", + "timeout": "3s" } ] } diff --git a/config/plugin/dns_problem.sh b/config/plugin/dns_problem.sh new file mode 100755 index 00000000..c31f7a66 --- /dev/null +++ b/config/plugin/dns_problem.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# This plugin checks for dns network issues. + +readonly OK=0 +readonly NONOK=1 +readonly UNKNOWN=2 + +readonly KUBERNETES_SERVICE='kubernetes.default' + +# Check getent command is present +if ! command -v getent >/dev/null; then + echo "Could not find 'getent' - require getent" + exit $UNKNOWN +fi + +# Return success if a DNS lookup to the Kubernetes host is successful +if getent hosts "${KUBERNETES_SERVICE}" >/dev/null; then + echo "DNS lookup to ${KUBERNETES_SERVICE} is working" + exit $OK +else + echo "DNS lookup to ${KUBERNETES_SERVICE} is not working" + exit $NONOK +fi From bc3150aa62be4b930e1402927368ed736294e345 Mon Sep 17 00:00:00 2001 From: Adrian Moisey Date: Mon, 22 Sep 2025 15:11:07 +0200 Subject: [PATCH 2/2] Update config/plugin/dns_problem.sh Co-authored-by: Dan Winship --- config/plugin/dns_problem.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/plugin/dns_problem.sh b/config/plugin/dns_problem.sh index c31f7a66..231f6829 100755 --- a/config/plugin/dns_problem.sh +++ b/config/plugin/dns_problem.sh @@ -14,7 +14,7 @@ if ! command -v getent >/dev/null; then exit $UNKNOWN fi -# Return success if a DNS lookup to the Kubernetes host is successful +# Return success if a DNS lookup of the kubernetes service is successful if getent hosts "${KUBERNETES_SERVICE}" >/dev/null; then echo "DNS lookup to ${KUBERNETES_SERVICE} is working" exit $OK