Check_MK's public GIT repository

This is the public GIT repository of Check_MK, a unique Addon for Nagios developed by Mathias Kettner.
This also contains MK Livestatus, a new Nagios event broker module that is a very fast and efficient replacement for NDO.

You can create your local clone of Check_MK with:
git clone http://git.mathias-kettner.de/check_mk.git
#1377 Renamed agent plugin resolve_hostname into dnsclient, make portable to all...
authorMathias Kettner <mk@mathias-kettner.de>
Sun, 24 Aug 2014 16:15:09 +0000 (18:15 +0200)
committerMathias Kettner <mk@mathias-kettner.de>
Sun, 24 Aug 2014 16:15:09 +0000 (18:15 +0200)
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 [new file with mode: 0644]
ChangeLog
agents/plugins/dnsclient [moved from agents/plugins/resolve_hostname with 76% similarity]

diff --git a/.werks/1377 b/.werks/1377
new file mode 100644 (file)
index 0000000..81eeb05
--- /dev/null
@@ -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.
+
index 4aabe78..ef7e7f4 100644 (file)
--- 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
similarity index 76%
rename from agents/plugins/resolve_hostname
rename to agents/plugins/dnsclient
index c14b19f..403a8ce 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # +------------------------------------------------------------------+
 # |             ____ _               _        __  __ _  __           |
 # |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
 # 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