discover_tfs.sh感知tfs

  sre

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


pids=`ps aux | grep -v grep | grep -v ps.sh|grep nameserver | grep tfs |  awk '{print 2}'`
path=`locate bin/ssm | head -n 1 | awk '{print substr(0,0,length(0)-3)}'`
discover_tfs_json=""

for pid inpid
do
    port=`netstat -lnp | grep pid/htfs | grep tcp | grep -v "127.0.0.1" | awk '{print4}' | awk -F ':' '{print NF}'`
    if [ "port" != "" ];then
        discover_tfs_json="discover_tfs_json{'cpname':'tfs','port':'port','path':'path','name':'Tfs组件模板','flag':'pid'},"
    else
        discover_tfs_json="discover_tfs_json{'cpname':'tfs','path':'path','name':'Tfs组件模板','flag':'pid'},"
    fi
done
result="[{discover_tfs_json%,*}]"
result=`echo {result//\'/\"}`
echoresult

LEAVE A COMMENT

Captcha Code