5f69949508f878875.jpg_fo742.png

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

pids=`ps aux | grep -v grep | grep -v ps.sh | grep org.apache.flume.node.Application | grep java | grep -v "uoamp" | awk '{print $2}'`
discover_flume_json=""

for pid in $pids
do
    port=`netstat -lnp | grep $pid/java | grep tcp | grep -v "127.0.0.1" | awk '{print $4}'|awk -F ':' '{print $NF}'`
    psinfo=`ps aux | grep $pid|grep java|grep -v ps|grep -v grep`
    config_path=`echo $psinfo|awk -F ' ' '{for(i=1;i<NF;++i){if(index($i,"-cp")==1)print $(i+1)}}'|awk -F ':' '{print $1}'`
    if [ "$port" != "" ];then
        discover_flume_json="$discover_flume_json{'cpname':'flume','port':'$port','path':'$config_path','name':'Flume组件模板','flag':'$pid'},"
    else
        discover_flume_json="$discover_flume_json{'cpname':'flume','path':'$config_path','name':'Flume组件模板','flag':'$pid'},"
    fi
    #cd  $config_path/../
done
result="[${discover_flume_json%,*}]"
result=`echo ${result//\'/\"}`
echo $result

发表评论

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

Captcha Code