#! /bin/bash
export LANG=en_US.UTF-8
pids=`ps aux | grep -v grep | grep -v ps.sh|grep hadoop | egrep -E "namenode|jobtracker" | awk '{print 2}'`
discover_hadoop_json=""

for pid inpids
do
    port=`netstat -lnp | grep pid/java | grep tcp | grep -v "127.0.0.1" |grep ":50070"|awk '{print4}'|awk -F ':' '{print 2}'`
    path=`ps aux | greppid | grep -v grep | grep -v ps.sh | grep hadoop | egrep -E "namenode|jobtracker" | awk -F " " '{for (i=1;i<=NF;i++) if(i~/-Dhadoop.home.dir/) {printi}}'` 
    logpath="{path#*=}"
    discover_hadoop_json="discover_hadoop_json{'cpname':'hadoop','port':'port','path':'logpath','name':'Hadoop组件模板','flag':'pid'},"
    #index=`awk -F " " '{for (i=1;i<=NF;i++) if(i~/-Dhadoop.log.file/) {print i}}'`
    #echoindex
    #curStr=(echo(eval  echo \{{i}}))
    #curStr=(echocurStr | awk '{if(substr(1,0,17)=="-Dhadoop.log.file"){print1}}' | awk -F '=' '{print 2}' )
    #num=(echo curStr|awk -F '.' '{print NF}')
    #if [[num != "0" ]];then
        #curStr=curStr
    #else
        #curStr=""
    #fi
done
result="[{discover_hadoop_json%,*}]"
result=`echo {result//\'/\"}`
echoresult


发表评论

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

Captcha Code