parent
f8c4cbafcd
commit
4ae6b3b94b
4 changed files with 181 additions and 17 deletions
@ -0,0 +1,58 @@ |
||||
#!/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. |
||||
|
||||
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 |
@ -0,0 +1,65 @@ |
||||
#!/bin/bash |
||||
|
||||
while test $# -gt 0; do |
||||
case $1 in |
||||
(-h|--help) cat <<EOF |
||||
$0 [OPTIONS] source-volume target-volume target-user target-host |
||||
|
||||
-h, --help show this help |
||||
|
||||
source-volume replication source volume name |
||||
target-volume replication target volume name |
||||
target-user replication target user name |
||||
target-host replication target host name |
||||
|
||||
DESCRIPTION |
||||
|
||||
Icinga plugin to check gluster geo replication. Returns OK, if no |
||||
connection is Faulty and one connection is Active. Returns CRITICAL, |
||||
if one connection is Faulty- Returns WARNING, if no connection is |
||||
Active. |
||||
|
||||
EOF |
||||
exit;; |
||||
(*) if test $# -ne 4; then |
||||
echo "ERROR: wrong number of options $*" 1>&2 |
||||
exit 2 |
||||
fi |
||||
sourcevolume=$1 |
||||
targetvolume=$2 |
||||
replicationuser=$3 |
||||
targethost=$4 |
||||
break;; |
||||
esac |
||||
if test $# -lt 1; then |
||||
echo "ERROR: missing option, try $0 --help" |
||||
exit 2 |
||||
fi |
||||
shift |
||||
done |
||||
if test $# -ne 4; then |
||||
echo "ERROR: wrong number of options $*" 1>&2 |
||||
exit 2 |
||||
fi |
||||
|
||||
rep=$(sudo gluster volume geo-replication \ |
||||
${sourcevolume} \ |
||||
${replicationuser}@${targethost}::${targetvolume} \ |
||||
status \ |
||||
| awk 'BEGIN {status="OK"; res=""} NR>3 {res=res " - " $1 " → " $7} NR>3 && $7=="Faulty" {status="CRITICAL"} END {print status res}') |
||||
if test $? -ne 0; then |
||||
echo "CRITICAL - wrong configuration" |
||||
exit 2 |
||||
elif [[ $rep =~ ^OK ]]; then |
||||
if [[ $rep =~ Active ]]; then |
||||
echo $rep |
||||
exit 0 |
||||
else |
||||
echo WARNING${rep#OK} |
||||
exit 1 |
||||
fi |
||||
else |
||||
echo $rep |
||||
exit 2 |
||||
fi |
||||
|
Loading…
Reference in new issue