[checkmk-commits] Check_MK Git: check_mk: nfsmounts: works now also in AIX ( needs GNU stat installed)

Mathias Kettner mk at mathias-kettner.de
Mon Aug 25 13:28:32 CEST 2014


Module: check_mk
Branch: master
Commit: 3e278bc41824216053ec67cef2a5e503be80c8d6
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3e278bc41824216053ec67cef2a5e503be80c8d6

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Mon Aug 25 13:26:51 2014 +0200

nfsmounts: works now also in AIX (needs GNU stat installed)

---

 agents/check_mk_agent.aix |   41 +++++++++++++++++++++++++++++++++++++++++
 checkman/nfsmounts        |    2 +-
 checks/nfsmounts          |    9 +++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/agents/check_mk_agent.aix b/agents/check_mk_agent.aix
index bed8bad..d5d3e11 100755
--- a/agents/check_mk_agent.aix
+++ b/agents/check_mk_agent.aix
@@ -51,6 +51,36 @@ else
     exec <&- 2>/dev/null
 fi
 
+# Shell version of the waitmax utility, that limits the runtime of
+# commands. This version does not conserve the original exit code
+# of the command. It is successfull if the command terminated
+# in time.
+function waitmax
+{
+   TIMEOUT=${1}0
+   SIGNAL=9
+   shift
+
+   # Run command in background
+   ksh -c "$*" &
+   PID=$!
+
+   # Wait for termination within TIMOUT seconds
+   while [ $TIMEOUT -gt 0 ]
+   do
+       TIMEOUT=$((TIMEOUT - 1))
+       if [ ! -e /proc/$PID ] ; then
+           return 0
+       fi
+       perl -e "select(undef, undef, undef, 0.1);"
+   done
+
+   # Process did not terminate in time. Kill and
+   # return with an error
+   kill -9 $PID
+   return 255
+}
+
 echo '<<<check_mk>>>'
 echo Version: 1.2.5i6
 echo AgentOS: aix
@@ -58,6 +88,17 @@ echo AgentOS: aix
 echo '<<<df>>>'
 df -kP | sed 's/ / - /' | grep -v ^/proc | grep -v ^Filesystem | grep -v :
 
+# Check for hanging NFS mounts. This needs a GNU stat installed in the PATH
+if type stat >/dev/null 2>&1 ; then
+    echo '<<<nfsmounts>>>'
+     mount | grep ' nfs' | awk '{print $3;}' | \
+        while read MP
+	do
+	    waitmax 2 stat -f -c '"'$MP' ok - - - -"' "$MP" || \
+		echo "$MP hanging 0 0 0 0"
+	done
+fi
+
 echo '<<<ps>>>'
 ps -ef -F user,vszsize,rssize,pcpu,args | sed -e 1d -e 's/ *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) *\([^ ]*\) */(\1,\2,\3,\4) /'
 
diff --git a/checkman/nfsmounts b/checkman/nfsmounts
index 3adcc16..c067b57 100644
--- a/checkman/nfsmounts
+++ b/checkman/nfsmounts
@@ -1,5 +1,5 @@
 title: Health of NFS mounts
-agents: linux
+agents: linux, aix
 catalog: os/services
 license: GPL
 distribution: check_mk
diff --git a/checks/nfsmounts b/checks/nfsmounts
index 6d5a1a0..a705cab 100644
--- a/checks/nfsmounts
+++ b/checks/nfsmounts
@@ -36,6 +36,15 @@ def check_nfsmounts(item, _no_params, info):
     for line in info:
         mountpoint = " ".join(line[:-5])
         if mountpoint == item:
+            # On some operating systems there is no information about
+            # used and free space, but just dahshes (e.g. AIX)
+            if line[-4] == '-':
+                if line[-5] == 'ok':
+                   return 0, "NFS mount seems OK"
+                else:
+                   return 2, "Server not responding"
+
+
             size_blocks = int(line[-4])
             free_blocks = int(line[-2]) # for non-root user
             blocksize = int(line[-1])



More information about the checkmk-commits mailing list