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


pid=`ps aux | grep -v grep | grep -v ps.sh | grep solr | grep -v discover_solr.sh | awk '{print 2}' `
ip=`ifconfig 2>/dev/null|sed -n 2p|awk  '{ print2 }'|awk -F : '{ print 2 }' `
if [[ "ip" == "" ]];then
    ip=`ifconfig 2>/dev/null|sed -n 2p|awk  '{ print 2 }'`
fi

http_port=
discover_solr_json=""

for pid inpid
do
    ports=`netstat -lntp|grep pid|awk '{print4}'|awk -F ':' '{print NF}'`
    for p inports
    do
       req_url='http://'ip':'p'/'
       http_code=`curl -s req_url -w%{http_code} 2>/dev/null -o /dev/null`
       if [[ "http_code" -gt 199 ]];then
            http_port=p
            break
       fi
    done
    path=`ps aux|greppid|grep -v grep|awk '{for(i=1;i<=NF;++i){if(index(i,"Dcatalina.home")>1)printi}}'|head -1|awk -F '=' '{print 2}'`
    if [[ "path" == "" ]];then
        path=`ps aux|grep pid|grep -v grep|awk '{for(i=1;i<=NF;++i){if(index(i,"Dsolr.install.dir")>1)print i}}'|head -1|awk -F '=' '{print2}'`
    fi
    discover_solr_json="discover_solr_json{'cpname':'solr','port':'http_port','name':'Solr组件模板','path':'path','flag':'pid'},"
done

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

发表评论

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

Captcha Code