From f4e214f80c2cbd5d3f13dee7a6686486efb93a54 Mon Sep 17 00:00:00 2001 From: mwaeckerlin Date: Tue, 3 Oct 2017 13:55:10 +0200 Subject: [PATCH] new check mountpoint --- README.md | 9 +++++++- load_per_cpu.sh | 5 +++-- mountpoint.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 mountpoint.sh diff --git a/README.md b/README.md index 468d969..b9b7371 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,11 @@ load_per_cpu.sh Icinga plugin to check load average per CPU. Shows 1min, 5min 15min average per CPU. Different to check_load, the load is divided by the number of CPU units and therefore normalized. So the same warning and -critical levels fit for any server. \ No newline at end of file +critical levels fit for any server. + +mountpoint.sh +------------- + +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". Called with path to check. \ No newline at end of file diff --git a/load_per_cpu.sh b/load_per_cpu.sh index 58e9749..aaff664 100755 --- a/load_per_cpu.sh +++ b/load_per_cpu.sh @@ -9,9 +9,12 @@ $0 [OPTIONS] OPTIONS + -h, --help show this help + -w, --warning "a b c" set warning threshold for: a: 1min, b: 5min, c: 15min average (default: ${WARNING[@]}) + -c, --critical "a b c" set critical threshold for: a: 1min, b: 5min, c: 15min average (default: ${CRITICAL[@]}) @@ -35,8 +38,6 @@ EOF shift done -a=( $(cut -d' ' -f 1-3 &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