====== nfs ====== ^ Author | [[ michael.adelmann@gmail.com | mikadel ]] | ^ Compatibility | Xymon 4.3.0 | ^ Requirements | Linux/Unix, killdog | ^ Download | None | ^ Last Update | 2012-01-03 | ===== Description ===== This is a shell script that is able to monitor NFS shares(/mount points) on the local machine. To prevent itself from getting stuck at unreachable mount points this test uses 'killdog'. 'killdog' is a shell script that executes a command/process, writes its' output to standard out and returns as soon as the command has been executed or (if the process is stuck) after a given timeout and kills the executed child process. {{:monitors:nfs.png?400|}} This test needs to be configurated via a config file (feel free to change its' name or location). A correctly mounted nfs share is shown as green entry, failures are represented by a red entry and not responding shares (which means that the 'killdog' timeout has been exceeded) will show up as yellow (you may want to change this behaviour to red). ===== Installation ===== === Client side === Create the following files in your xymon client directory: monitoring script: /nfs monitoring config: /nfs.conf xymon monitor config: /clientlaunch.d/nfs.cfg 'killdog' has to be placed somewhere where it can be executed via $PATH or directly in the directory. Depending on where you place it you may have to change your sudoers files to something like this: hobbit ALL=NOPASSWD://killdog === Server side === None. ===== Source ===== ==== killdog ==== #!/bin/bash PID="" function check() { "$1" 2>&1 & PID="$!" } function watchdog() { RES=`ps -ef | grep "$PID" | grep -v "grep $PID"` if [ -z "$RES" ]; then exit else sleep $1 echo "killed by timeout!" kill $PID 2>/dev/null fi } # main check "$1" watchdog "$2" ==== nfs ==== #!/bin/bash COLOR="green" COLUMN="nfs" COMMAND="/usr/local/bin/killdog" CONFIG="${HOBBITCLIENTHOME}/etc/nfs.conf" MSG="" # read config file source $CONFIG RESULT=`$COMMAND "mount" $TIMEOUT` for MP in "${MOUNT[@]}" do CONTENT=`echo -e "$RESULT" | grep $MP` if [ -n "$CONTENT" ]; then if [ -n "`echo -e $CONTENT | grep \"killed by timeout!\"`" ]; then MSG=`echo -e "$MSG\n\n&yellow $MP: timeout!\n"` else MSG=`echo -e "$MSG\n\n&green $MP: successfully mounted.\n"` fi else COLOR="red" MSG=`echo -e "$MSG\n\n&red $MP: failed!\n"` fi done $BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date` $MSG" ==== nfs.cfg ==== [nfs] ENVFILE /etc/hobbit/hobbitclient.cfg CMD $HOBBITCLIENTHOME/ext/nfs LOGFILE /var/log/hobbit/nfs.log INTERVAL 5m ==== nfs.conf ==== # nfs test configuration # mount points to check MOUNT[0]="/media/athene" MOUNT[1]="/media/bla" # timeout in seconds TIMEOUT=5 ===== Known Bugs and Issues ===== None currently known. ===== To Do ===== ===== Credits ===== ===== Changelog ===== * **2012-01-03** * Initial release