#!/bin/bash while test $# -gt 0; do case $1 in (-h|--help) cat <&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