Module: check_mk
Branch: master
Commit: 9a0257d54701e788f7097fb4c3a87482181d18fa
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9a0257d54701e7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Aug 24 18:15:09 2014 +0200
#1377 Renamed agent plugin resolve_hostname into dnsclient, make portable to all Unices
The small agent plugin <tt>dnsclient</tt> simply uses
<tt>nslookup</tt> in order
to try the local resolver. It now should work on Linux, AIX, HP-UX and Solaris,
provided the tool <tt>nslookup</tt> is installed and in the search path. It
now also supports resolving several addresses.
---
.werks/1377 | 13 +++++++++++
ChangeLog | 1 +
agents/plugins/{resolve_hostname => dnsclient} | 28 ++++++++++++++----------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/.werks/1377 b/.werks/1377
new file mode 100644
index 0000000..81eeb05
--- /dev/null
+++ b/.werks/1377
@@ -0,0 +1,13 @@
+Title: Renamed agent plugin resolve_hostname into dnsclient, make portable to all Unices
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1408896816
+Class: feature
+
+The small agent plugin <tt>dnsclient</tt> simply uses
<tt>nslookup</tt> in order
+to try the local resolver. It now should work on Linux, AIX, HP-UX and Solaris,
+provided the tool <tt>nslookup</tt> is installed and in the search path. It
+now also supports resolving several addresses.
+
diff --git a/ChangeLog b/ChangeLog
index 4aabe78..ef7e7f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,7 @@
NOTE: Please refer to the migration notes!
* 1375 vxvm_enclosures, vxvm_multipath, vxvm_objstatus: joined into one agent plugin
called vxvm...
* 1376 dmraid: moved plugin code into normal Linux agent...
+ * 1377 Renamed agent plugin resolve_hostname into dnsclient, make portable to all
Unices...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/agents/plugins/resolve_hostname b/agents/plugins/dnsclient
similarity index 76%
rename from agents/plugins/resolve_hostname
rename to agents/plugins/dnsclient
index c14b19f..403a8ce 100755
--- a/agents/plugins/resolve_hostname
+++ b/agents/plugins/dnsclient
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
@@ -27,18 +27,22 @@
# address using the local resolver of the system this script is
# running on.
-HOSTADDRESS=mathias-kettner.de
+HOSTADDRESSES=mathias-kettner.de
-OUTPUT=$(nslookup $HOSTADDRESS 2>&1)
-RC=$?
-if [ $RC -ne 0 ]; then
- STATE=2
- OUTPUT="CRIT - $HOSTADDRESS could not be resolved"
-else
- STATE=0
- ADDRESSES=$(echo "$OUTPUT" | tail -n+3 | grep Address: | cut -d"
" -f2)
- OUTPUT="OK - $HOSTADDRESS resolved to ${ADDRESSES//$'\n'/, }"
+if [ -e $MK_CONFDIR/dnsclient.cfg ] ; then
+ . $MK_CONFDIR/dnsclient.cfg
fi
echo "<<<mrpe>>>"
-echo "Resolve_$HOSTADDRESS $STATE $OUTPUT"
+for HOSTADDRESS in $HOSTADDRESSES
+do
+ ADDRESSES=`nslookup $HOSTADDRESS | sed -n -e 1,3d -e '/^Address:
*\(.*\)$/s//\1/p'`
+ if [ ! "$ADDRESSES" ] ; then
+ STATE=2
+ OUTPUT="CRIT - $HOSTADDRESS could not be resolved"
+ else
+ STATE=0
+ OUTPUT="OK - $HOSTADDRESS resolved into $ADDRESSES"
+ fi
+ echo Resolve_$HOSTADDRESS $STATE $OUTPUT
+done