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

pids=`ps aux | grep activemq | grep java | grep -v org.apache.catalina.startup.Bootstrap | awk '{print 2}'`
discover_mq_json=""

for pid inpids
do
    wrapper_pid=`ps aux|grep pid|grep -v grep|awk '{for(i=1;i<=NF;++i){if(index(i,"Dwrapper.pid")>1)print i}}'|head -1|awk -F '=' '{print2}'`
    if [[ "wrapper_pid" != "" ]];then
        wrapper_pidfile=`ps aux|grepwrapper_pid|grep -v grep|grep -v pid|awk '{for(i=1;i<=NF;++i){if(index(i,"pidfile")>1)print i}}'|head -1|awk -F '=' '{print2}'`
        if [ -e "wrapper_pidfile" ];then
        wrapper_pidfile_path=`dirname "wrapper_pidfile"`
        cd wrapper_pidfile_path
    fi
    fi
    target_jar_file=`ps aux|greppid|grep -v grep|awk '{for(i=1;i<=NF;++i){if(index(i,"Dactivemq.home")>1)printi}}'|head -1|awk -F '=' '{print 2}'`
    pwd=
    if [ -d "target_jar_file" ];then
        cd target_jar_file
        pwd=(echo `pwd`)
        cd conf
        ss=`cat activemq.xml|grep -v '<!\-\-'|grep "openwire"`
        ports=`echo ss | awk -F ':' '{print3}' | awk -F '?' '{print 1}' |sed 's/ //g'`
    fi
    if [ "ports" != "" ];then
        discover_mq_json="discover_mq_json{'cpname':'activemq','port':'ports','path':'pwd','pid':'pid'},"
    fi

done
result="[{discover_mq_json%,*}]"
result=`echo{result//\'/\"}`
echo $result

发表评论

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

Captcha Code