5fc7e2e5657922154.jpg_fo742.jpg

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

updatedb
mongospath=`locate bin/mongod | head -n 1 | awk '{print substr(0,0,length(0)-6)}'`

pids=`ps aux | grep -v grep | grep -v ps.sh|grep ./mongos | grep -v java | awk '{print 2}'`
discover_mongos_json=""

for pid inpids
do
    ports=`netstat -lntp|grep pid/ | awk '{print4}'|awk -F ':' '{print NF}'`
    if [ "ports" != "" ];then
        for p in ports
        do
            discover_mongos_json="discover_mongos_json{'cpname':'mongos','port':'p','path':'mongospath','flag':'pid'},"
        done
    else
        discover_mongos_json="discover_mongos_json{'cpname':'mongos','path':'mongospath','flag':'pid'},"
    fi
done
result="[{discover_mongos_json%,*}]"
result=`echo{result//\'/\"}`
echo $result





发表评论

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

Captcha Code