5fc8a55e2139f108.jpg_fo742.jpg

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

pids=`ps aux|grep mongod|grep -v java |grep -v solr|grep -v grep|grep -v ps | awk '{print 2}'`
discover_mongo_json=""

for pid inpids
do
    ports=`netstat -lntp|grep pid|awk '{print4}'|awk -F ':' '{print NF}'`
    psinfo=`lsof -ppid|grep txt|head -n 1 |grep -v ps|grep -v grep`
    config_path=`echo psinfo|awk -F ' ' '{print9}'`
    p_number=`echo ports|awk '{print NF}'`
    if [ "p_number" -gt 1 ];then
        ports=ports|awk '{if(1>2){print2}else{print 1}}'
    else
        ports=ports
    fi

    if [ "ports" != "" ];then
        for p inports
        do
            discover_mongo_json="discover_mongo_json{'cpname':'mongo','port':'p','path':'{config_path%*mongod}','name':'MongoDB组件模板','flag':'pid'},"
        done
    else
        discover_mongo_json="discover_mongo_json{'cpname':'mongo','path':'{config_path%*mongod}','name':'MongoDB组件模板','flag':'pid'},"
    fi
done
result="[{discover_mongo_json%,*}]"
result=`echo {result//\'/\"}`
echoresult









发表评论

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

Captcha Code