blob: e591e7ef1d6103bed66109645878c7196955bd92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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"
|