parent
8744a79b18
commit
f4e214f80c
3 changed files with 67 additions and 3 deletions
@ -0,0 +1,56 @@ |
|||||||
|
#!/bin/bash |
||||||
|
|
||||||
|
path="" |
||||||
|
while test $# -gt 0; do |
||||||
|
case $1 in |
||||||
|
(-h|--help) cat <<EOF |
||||||
|
$0 [OPTIONS] PATH |
||||||
|
|
||||||
|
-h, --help show this help |
||||||
|
|
||||||
|
PATH |
||||||
|
|
||||||
|
Path to check. |
||||||
|
|
||||||
|
DESCRIPTION |
||||||
|
|
||||||
|
Icinga plugin to check whether a given path is available. Detects |
||||||
|
problems, e.g. with glusterfs: In case of a problem, there is an error |
||||||
|
message such as "socket not connected". |
||||||
|
|
||||||
|
EOF |
||||||
|
exit;; |
||||||
|
(*) if test $# -ne 1; then |
||||||
|
echo "ERROR: please specify an existing path, not $*" 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 -d "$path"; then |
||||||
|
echo "ERROR: no such path $path" 1>&2 |
||||||
|
exit 1 |
||||||
|
fi |
||||||
|
time=$(mktemp) |
||||||
|
out=$(mktemp) |
||||||
|
err=$(mktemp) |
||||||
|
if /usr/bin/time -f "elapsed=%es" -qo $time ls "$path" > $out 2> $err && test -s $out; then |
||||||
|
if [[ $(<$time) =~ elapsed=0.0[012]s ]]; then |
||||||
|
level=0 |
||||||
|
STATUS="OK - ${path}:" |
||||||
|
else |
||||||
|
level=1 |
||||||
|
STATUS="WARNING - ${path}:" |
||||||
|
fi |
||||||
|
else |
||||||
|
level=2 |
||||||
|
STATUS="CRITICAL - $(<$err):" |
||||||
|
fi |
||||||
|
echo ${STATUS} $(<$time) |
||||||
|
rm $time $out $err 2>&1 > /dev/null |
||||||
|
exit $level |
Loading…
Reference in new issue