Skip to content

Commit 545516f

Browse files
authored
Merge pull request #1080 from adrianmoisey/add-dns-test
Add DNS lookup plugin
2 parents b81221e + bc3150a commit 545516f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

config/network-problem-monitor.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
"reason": "ConntrackFull",
1616
"path": "./config/plugin/network_problem.sh",
1717
"timeout": "3s"
18+
},
19+
{
20+
"type": "temporary",
21+
"reason": "DNSUnreachable",
22+
"path": "./config/plugin/dns_problem.sh",
23+
"timeout": "3s"
1824
}
1925
]
2026
}

config/plugin/dns_problem.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# This plugin checks for dns network issues.
4+
5+
readonly OK=0
6+
readonly NONOK=1
7+
readonly UNKNOWN=2
8+
9+
readonly KUBERNETES_SERVICE='kubernetes.default'
10+
11+
# Check getent command is present
12+
if ! command -v getent >/dev/null; then
13+
echo "Could not find 'getent' - require getent"
14+
exit $UNKNOWN
15+
fi
16+
17+
# Return success if a DNS lookup of the kubernetes service is successful
18+
if getent hosts "${KUBERNETES_SERVICE}" >/dev/null; then
19+
echo "DNS lookup to ${KUBERNETES_SERVICE} is working"
20+
exit $OK
21+
else
22+
echo "DNS lookup to ${KUBERNETES_SERVICE} is not working"
23+
exit $NONOK
24+
fi

0 commit comments

Comments
 (0)