blob: adb2fea61d8177961b705be096ce62735e1e3f2d (
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
|
function volinfo_field()
{
local vol=$1;
local field=$2;
$CLI volume info $vol | grep "^$field: " | sed 's/.*: //';
}
function brick_count()
{
local vol=$1;
$CLI volume info $vol | egrep "^Brick[0-9]+: " | wc -l;
}
function volume_option()
{
local vol=$1
local key=$2
$CLI volume info $vol | egrep "^$key: " | cut -f2 -d' ';
}
function rebalance_status_completed_field {
$CLI volume rebalance $V0 status | awk '{print $6}' | sed -n 3p
}
function remove_brick_status_completed_field {
$CLI volume remove-brick $V0 $H0:$B0/r2d2_{4,5} status | awk '{print $6}' | sed -n 3p
}
function get_mount_process_pid {
local vol=$1
ps aux | grep glusterfs | grep -E "volfile-id[ =]/?$vol " | awk '{print $2}' | head -1
}
function generate_mount_statedump {
local vol=$1
local fpath=""
mount_pid=$(get_mount_process_pid $vol)
#remove old stale statedumps
rm -f /tmp/glusterdump.$mount_pid.dump.* 2>/dev/null
kill -USR1 $mount_pid
#Wait till the statedump is generated
sleep 1
fname=$(ls /tmp | grep -E "glusterdump.$mount_pid.dump.*")
echo /tmp/$fname
}
function afr_child_up_status {
local vol=$1
#brick_id is (brick-num in volume info - 1)
local brick_id=$2
local fpath=$(generate_mount_statedump $vol)
up=$(grep -B1 trusted.afr.$vol-client-$brick_id $fpath | head -1 | cut -f2 -d'=')
rm -f $fpath
echo "$up"
}
function glustershd_up_status {
gluster volume status | grep "Self-heal Daemon" | awk '{print $6}'
}
function kill_brick()
{
vol=$1
host=$2
brick=$3
brick_hiphenated=$(echo $brick | tr '/' '-')
kill -9 `cat /var/lib/glusterd/vols/$vol/run/${host}${brick_hiphenated}.pid`
}
function check_option_help_presence {
option=$1
$CLI volume set help | grep "^Option:" | grep -w $option
}
function afr_get_changelog_xattr {
file=$1
xkey=$2
getfattr -n $xkey -e hex $file 2>/dev/null | grep "client-" | cut -f2 -d'='
}
|