#! /bin/bash
export LANG=en_US.UTF-8


pids=`ps aux | egrep "HMaster|HRegionServer" | grep -v grep | grep -v "uoamp" | grep -v ps.sh | awk '{print $2}'`
discover_hbase_json=""

for pid in $pids
do
    port=`netstat -lnp | grep $pid/ | grep tcp | grep LISTEN | head -n 1 | awk '{print $4}'|awk -F ':' '{print $NF}'`
    if [ "$port" != "" ];then
        path=`ps aux|grep $pid|grep -v grep|awk '{for(i=1;i<=NF;++i){if(index($i,"Dhbase.home.dir")>1)print $i}}'|head -1|awk -F '=' '{print $2}'`
        discover_hbase_json="$discover_hbase_json{'cpname':'hbase','port':'$port','flag':$pid,'name':'Hbase组件模板','path':'$path'},"
    fi
done
result="[${discover_hbase_json%,*}]"
result=`echo ${result//\'/\"}`
echo $result

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code