[Nagiosplug-devel] Required improvements in check_disk

Holger Weiß holger at CIS.FU-Berlin.DE
Tue Apr 17 09:27:40 CEST 2012


* Mithun Gaikwad <mithun.gaikwad at gmail.com> [2012-04-17 09:52]:
> Is it possible to have check the disk is Read-Only or Red-Write.

check_disk is really just about the fill level.  I'd use a separate
plugin for testing other aspects of the file system.  The following
script should do the trick:

# -----------------------------------------------------------------
#!/bin/sh

if [ $# != 1 ]
then
	echo "UNKNOWN: Usage: $0 <directory>"
	exit 3
fi

directory=$1
tmpfile="$directory/.${0##*/}.XXXXXX"
output=`mktemp "$tmpfile" 2>&1`
status=$?

trap 'rm -f "$tmpfile"' EXIT

if [ $status -eq 0 ]
then
	echo "OK: $directory is writable"
	exit 0
else
	echo "CRITICAL: Cannot write to $directory: ${output##*: }"
	exit 2
fi
# -----------------------------------------------------------------

Holger




More information about the Devel mailing list