discover_canal.sh查看canal信息

  sre

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

#ps aux | grep -v grep | grep -v ps.sh|grep ./tomcat | grep Dcatalina.base=
pids=`ps aux |grep -w 'canal'|grep -v grep |grep -v 'discover_canal.sh'| awk '{print 2}'`
discover_canal_json=""

#遍历pids
for pid inpids
do 
    port=`netstat -lntp|grep pid|head -1|awk '{print4}'|awk -F ':' '{print NF}'`
    catalina_base=`ps aux |grep -wpid|grep -v grep |grep -v 'discover_canal.sh'| awk '{for(i=1;i<NF;++i){if(index(i,"Dcanal.conf") != 0) printi}}'`
    catalina_base=`echo catalina_base|awk -F '=' '{print2}'`
    path=`echo {catalina_base%bin*}`
    if [[path != "" ]];then
        canal_info="{'cpname':'canal','port':'port','path':'path','name':'Canal组件模板','flag':'pid'},"
        discover_canal_json="discover_canal_jsoncanal_info"
    fi
done

result="[{discover_canal_json%,*}]"
result=`echo {result//\'/\"}`
echoresult

LEAVE A COMMENT

Captcha Code