monitors:nfs

Error loading plugin struct
ParseError: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM)
More info is available in the error log.

nfs

Author mikadel
Compatibility Xymon 4.3.0
Requirements Linux/Unix, killdog
Download None
Last Update 2012-01-03

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.

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).

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.

Show Code ⇲

Hide 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"

Show Code ⇲

Hide 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"

Show Code ⇲

Hide Code ⇱

[nfs]
	ENVFILE /etc/hobbit/hobbitclient.cfg
	CMD $HOBBITCLIENTHOME/ext/nfs
	LOGFILE /var/log/hobbit/nfs.log
	INTERVAL 5m

Show Code ⇲

Hide Code ⇱

# nfs test configuration

# mount points to check
MOUNT[0]="/media/athene"
MOUNT[1]="/media/bla"

# timeout in seconds
TIMEOUT=5

None currently known.

  • 2012-01-03
    • Initial release
  • monitors/nfs.txt
  • Last modified: 2012/02/29 21:33
  • by 127.0.0.1