Hbase Region server summary - Useful for Troubleshooting

Shell script to collect the Hbase Region server summary report:-

It will be useful when working in command line and to monitor the Regions summary to troubleshoot the performance issues.

############Print header to Report ##############################
echo $'Region_Server\t#OnlineReg\tReq/S\tRd/S\tWr/S\tUsedHeapMB\tMemstoreMB\t#Stores\t#Store_Files\tStr_Files_size\tcompact_Prog_Pct\t#Compacting_KV\t#Curr_Compacted_KV \n' > /tmp/RS_Quick_Summary
############Get status detailed output from hbase shell##########
echo `date`
echo "Collecting RS detailed status ......"
echo "status 'detailed'" | hbase shell -n |grep -i maxHeapMB -B 1 | grep -v '\--' > /tmp/rs_status_raw_data
echo `date`
echo "Processing data....."
filename=/tmp/rs_status_raw_data
while read -r line
do
    name="$line"
############ Extract RS server name ##############################
if [[ $line == *":16020"* ]]; then
echo $line | awk '{print $1}' |cut -d':' -f 1 > /tmp/temp_rs_processing_data
rs_server=$(echo $line | awk '{print $1}' |cut -d':' -f 1)
else
############ Collect stats for each RS server from status output ############
echo $line | cut -d',' -f 1-50 --output-delimiter='' | awk -v FS=' ' -v OFS='\n' '{$1=$1}1' |grep -a -i '=' >> /tmp/temp_rs_processing_data
#
###########Metric collection######
onl_reg=$(grep -a -i numberOfOnlineRegions /tmp/temp_rs_processing_data | cut -d'=' -f 2 )
req_sec=$(grep -a -i requestsPerSecond /tmp/temp_rs_processing_data | cut -d'=' -f 2)
read_sec=$(grep -a -i readRequestsCount    /tmp/temp_rs_processing_data| cut -d'=' -f 2)
write_sec=$(grep -a -i writeRequestsCount /tmp/temp_rs_processing_data| cut -d'=' -f 2)
used_heap=$(grep -a -i usedHeapMB /tmp/temp_rs_processing_data| cut -d'=' -f 2)
memstore=$(grep -a -i memstoreSizeMB    /tmp/temp_rs_processing_data| cut -d'=' -f 2)
store_num=$(grep -a -i numberOfStores    /tmp/temp_rs_processing_data| cut -d'=' -f 2)
store_file_num=$(grep -a -i numberOfStorefiles /tmp/temp_rs_processing_data | cut -d'=' -f 2)
store_size=$(grep -a -i storefileSizeMB     /tmp/temp_rs_processing_data| cut -d'=' -f 2)
comp_pct=$(grep -a -i compactionProgressPct     /tmp/temp_rs_processing_data| cut -d'=' -f 2)
comp_in_pgrs=$(grep -a -i totalCompactingKVs /tmp/temp_rs_processing_data| cut -d'=' -f 2)
comp_complete=$(grep -a -i currentCompactedKVs /tmp/temp_rs_processing_data| cut -d'=' -f 2)
#############Print Collected information in a tab separated format############
echo $rs_server$'\t'$onl_reg$'\t'$req_sec$'\t'$read_sec$'\t'$write_sec$'\t'$used_heap$'\t'$memstore$'\t'$store_num$'\t'$store_file_num$'\t'$store_size$'\t'$comp_pct$'\t'$comp_in_pgrs$'\t'$comp_complete >> /tmp/RS_Quick_Summary
fi
done < "$filename"
############Displaying data in tab separated with formatted ##################
column -t /tmp/RS_Quick_Summary
##########Clearing Tempfiles created ####################
rm /tmp/temp_rs_processing_data /tmp/RS_Quick_Summary /tmp/rs_status_raw_data
##########################

Save it in a shell script for example  "RS_Quick_Summary.sh"  and the output will look the following.

Run this script as hbase user.  If kerberos enabled in the cluster , do a kinit before running this script.


No comments:

Post a Comment

Boost Your Download Speed with lftp Segmentation

Looking for a faster way to download files via sftp to a Linux machine? Try using "lftp" instead. This tool offers segmented downl...

Other relevant topics