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_client_statedump { local fpath="" client_pid=$1 #remove old stale statedumps rm -f $statedumpdir/glusterdump.$client_pid.dump.* 2>/dev/null kill -USR1 $client_pid #Wait till the statedump is generated sleep 1 fname=$(ls $statedumpdir | grep -E "glusterdump.$client_pid.dump.*") echo $statedumpdir/$fname } function generate_mount_statedump { local vol=$1 generate_client_statedump $(get_mount_process_pid $vol) } function _afr_child_up_status { local vol=$1 #brick_id is (brick-num in volume info - 1) local brick_id=$2 local gen_state_dump=$3 local fpath=$($gen_state_dump $vol) up=$(grep -B1 trusted.afr.$vol-client-$brick_id $fpath | head -1 | cut -f2 -d'=') rm -f $fpath echo "$up" } function afr_child_up_status { local vol=$1 #brick_id is (brick-num in volume info - 1) local brick_id=$2 _afr_child_up_status $vol $brick_id generate_mount_statedump } function get_shd_process_pid { local vol=$1 ps aux | grep glusterfs | grep -E "glustershd/run/glustershd.pid" | awk '{print $2}' | head -1 } function generate_shd_statedump { local vol=$1 generate_client_statedump $(get_shd_process_pid $vol) } function afr_child_up_status_in_shd { local vol=$1 #brick_id is (brick-num in volume info - 1) local brick_id=$2 _afr_child_up_status $vol $brick_id generate_shd_statedump } function glustershd_up_status { gluster volume status | grep "Self-heal Daemon" | awk '{print $6}' } function kill_brick() { local vol=$1 local host=$2 local 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 { local option=$1 $CLI volume set help | grep "^Option:" | grep -w $option } function afr_get_changelog_xattr { local file=$1 local xkey=$2 getfattr -n $xkey -e hex $file 2>/dev/null | grep "client-" | cut -f2 -d'=' } function afr_get_pending_heal_count { local vol=$1 gluster volume heal $vol info | grep "Number of entries" | awk '{ sum+=$4} END {print sum}' } function afr_get_index_path { local brick_path=$1 echo "$brick_path/.glusterfs/indices/xattrop" } function afr_get_num_indices_in_brick { local brick_path=$1 echo $(ls $(afr_get_index_path $brick_path) | grep -v xattrop | wc -l) }