Files
icinga-checks/gluster-geo-replication.sh

66 lines
1.7 KiB
Bash
Raw Permalink Normal View History

#!/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