diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2018-04-16 10:30:15 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2018-04-16 10:30:15 +0200 |
commit | 55783753ae8f2d857a7225b7a93c1d47039e5a90 (patch) | |
tree | e077b61b0f004141712e7d16876f9c19175ac681 /service/check_gluster.sh | |
download | conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.gz conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.bz2 conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.tar.xz conky-55783753ae8f2d857a7225b7a93c1d47039e5a90.zip |
OpenShift monitoring
Diffstat (limited to 'service/check_gluster.sh')
-rwxr-xr-x | service/check_gluster.sh | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/service/check_gluster.sh b/service/check_gluster.sh new file mode 100755 index 0000000..e591e7e --- /dev/null +++ b/service/check_gluster.sh @@ -0,0 +1,83 @@ +#! /bin/bash + +cd "$(dirname "$0")" +. opts.sh + +if [ -f "../security/$host.kubeconfig" ]; then + gpod=$(get_gluster_pod) + + function gluster { + oc -n glusterfs rsh po/$gpod gluster "$@" + } + +# check if gluster pods are running + if [ -n "$gpod" ]; then + online=1 + else + oc -n glusterfs get pods -l 'glusterfs=storage-pod' | sed 's/^/* /' + online=0 + fi +else + echo "0 0 Not supported" + exit +fi + +function check { + vol=$1 + vol_bricks=$(gluster volume info "$vol" | grep -P 'Number of Bricks' | awk '{ print $NF }' | tr -d '\r\n') + vol_online=$(gluster volume status "$vol" detail | grep Online | grep Y | wc -l) + + if [ -z "$vol_bricks" -o -z "$vol_online" -o "$vol_bricks" -ne "$vol_online" ]; then + vol_status=$(gluster volume info "$vol" | grep -P 'Status' | awk '{ print $2 }' | tr -d '\r\n') + vol_avail=$(gluster volume status "$vol" detail | grep Brick | wc -l) + echo "* Volume $vol: $vol_status (Bricks: $vol_bricks, Available: $vol_avail, Online: $vol_online)" + + if [ "$vol_status" == "Started" -a "$vol_online" -ge 0 ]; then + return 2 + else + return 0 + fi + else + return 1 + fi +} + +version=$(gluster --version | head -n 1 | awk '{ print $2 }' | tr -d '\r') +if [ -z "$version" ]; then + online=0 +else + version="GlusterFS $version" +fi + +volumes=0 +partial=0 +failed=0 +healthy=$online + +if [ $online -eq 1 ]; then + vols=$(gluster volume info | grep -P '^Volume Name' | awk '{ print $NF }' | tr '\r\n' ' ') + for vol in $vols; do + [[ "$vol" =~ [0-9] ]] && continue + [[ "$vol" =~ ^vol_ ]] && continue + [[ "$vol" =~ ^heketi ]] && continue + check ${vol} + ret=$? + + volumes=$((volumes + 1)) + if [ $ret -eq 0 ]; then + healthy=0 + failed=$((failed + 1)) + elif [ $ret -ne 1 ]; then + [ $healthy -gt 0 ] && healthy=$ret + partial=$((partial + 1)) + fi + done +fi + +if [ $healthy -eq 1 ]; then + msg="\${color gray}/ $volumes volumes" +else + msg="\${color gray}/ $volumes volumes, $failed failed, $partial bricks missing" +fi + +echo "$online $healthy $version $msg" |