Differences

This shows you the differences between two versions of the page.

Link to this comparison view

monitors:nfs [2012/02/29 21:33] (current)
Line 1: Line 1:
 +====== 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: <​xymon-client-ext>/​nfs
 +
 +monitoring config: <​xymon-client-etc>/​nfs.conf
 +
 +xymon monitor config: <​xymon-client-etc>/​clientlaunch.d/​nfs.cfg
 +
 +'​killdog'​ has to be placed somewhere where it can be executed via $PATH or directly in the <​xymon-client-ext>​ directory. Depending on where you place it you may have to change your sudoers files to something like this:
 +
 +hobbit ALL=NOPASSWD:/<​your-path-to-killdog>/​killdog
 +
 +=== Server side ===
 +
 +None.
 +
 +===== Source =====
 +==== killdog ====
 +
 +<hidden onHidden="​Show Code ⇲" onVisible="​Hide Code ⇱">​
 +<​code>​
 +#!/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"​
 +</​code>​
 +</​hidden>​
 +
 +==== nfs ====
 +
 +<hidden onHidden="​Show Code ⇲" onVisible="​Hide Code ⇱">​
 +<​code>​
 +#!/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<​b>&​yellow $MP:</​b>​ timeout!\n"​`
 + else
 + MSG=`echo -e "​$MSG\n\n<​b>&​green $MP:</​b>​ successfully mounted.\n"​`
 + fi
 + else
 + COLOR="​red"​
 +         MSG=`echo -e "​$MSG\n\n<​b>&​red $MP:</​b>​ failed!\n"​`
 + fi
 +done
 +
 +$BB $BBDISP "​status $MACHINE.$COLUMN $COLOR `date` $MSG"
 +</​code>​
 +</​hidden>​
 +
 +==== nfs.cfg ====
 +
 +<hidden onHidden="​Show Code ⇲" onVisible="​Hide Code ⇱">​
 +<​code>​
 +[nfs]
 + ENVFILE /​etc/​hobbit/​hobbitclient.cfg
 + CMD $HOBBITCLIENTHOME/​ext/​nfs
 + LOGFILE /​var/​log/​hobbit/​nfs.log
 + INTERVAL 5m
 +</​code>​
 +</​hidden>​
 +
 +==== nfs.conf ====
 +
 +<hidden onHidden="​Show Code ⇲" onVisible="​Hide Code ⇱">​
 +<​code>​
 +# nfs test configuration
 +
 +# mount points to check
 +MOUNT[0]="/​media/​athene"​
 +MOUNT[1]="/​media/​bla"​
 +
 +# timeout in seconds
 +TIMEOUT=5
 +</​code>​
 +</​hidden>​
 +
 +===== Known  Bugs and Issues =====
 +None currently known.
 +===== To Do =====
 +
 +===== Credits =====
 +
 +===== Changelog =====
 +
 +  * **2012-01-03**
 +    * Initial release
  
  • monitors/nfs.txt
  • Last modified: 2012/02/29 21:33
  • (external edit)