You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if test -e /etc/doskio.conf; then
|
|
|
|
. /etc/doskio.conf
|
|
|
|
fi
|
|
|
|
|
|
|
|
path=( ${CHECKPATHES} )
|
|
|
|
filename=tmp/test.${HOSTNAME}
|
|
|
|
while test $# -gt 0; do
|
|
|
|
case $1 in
|
|
|
|
(-h|--help) cat <<EOF
|
|
|
|
$0 [OPTIONS] PATH…
|
|
|
|
|
|
|
|
-h, --help show this help
|
|
|
|
-t, --tmpfile <filename> filename for temporary file (default: ${filename})
|
|
|
|
|
|
|
|
PATH
|
|
|
|
|
|
|
|
Path to check.
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
|
|
|
Icinga plugin to check whether a given path is writable and checks the
|
|
|
|
performance of the given path. Detects problems with the filesystem or
|
|
|
|
specific io performance. Writes a test file using `dd` and reports
|
|
|
|
write speed. It is recommended to use a subdirectory tmp for writing
|
|
|
|
test files.
|
|
|
|
|
|
|
|
EOF
|
|
|
|
exit;;
|
|
|
|
(-t|--tmpfile) shift; filename=$1;;
|
|
|
|
(*) if ! test -d $1; then
|
|
|
|
echo "ERROR: please specify an existing path, not $1" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
path+=( "$1" );;
|
|
|
|
esac
|
|
|
|
if test $# -lt 1; then
|
|
|
|
echo "ERROR: missing option, try $0 --help"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
if test ${#path[@]} -eq 0; then
|
|
|
|
echo "ERROR: missing path, try $0 --help"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
result=0
|
|
|
|
for file in "${path[@]}"; do
|
|
|
|
check=$(dd if=/dev/zero of=${file}/${filename} bs=2M count=2 iflag=fullblock 2>&1 | sed -n 's/.*, *\([^, ]*\) *\([^, ]*\), *\([^ ,]*\) *\([^, ]*\)/'"${file//\//\\/}"'; time=\1\2 speed=\3\4/p')
|
|
|
|
status=$?
|
|
|
|
if rm ${file}/${filename} 2> /dev/null && test $status -eq 0; then
|
|
|
|
status="OK - $check"
|
|
|
|
else
|
|
|
|
status="CRITICAL - ${file}"
|
|
|
|
result=2
|
|
|
|
fi
|
|
|
|
echo ${status}
|
|
|
|
done
|
|
|
|
exit $result
|