diff --git a/config/network-problem-monitor.json b/config/network-problem-monitor.json index 7a4c48bf6..6b13f4365 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 000000000..c31f7a66f --- /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