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


pids=`ps aux |grep mysqld|grep -v mysqld_safe| grep -v grep | grep -v ps.sh | grep -v dump | awk '{print 2}'`
discover_mysql_json=""


for pid inpids
do
    ports=`netstat -lntp|grep pid/mysqld | awk '{print4}'|awk -F ':' '{print NF}'`
    config_path=`ls -l /proc/pid/exe | awk '{for(i=1;i<=NF;i++){if(i ~ /mysqld/) printi}}'`
    #echo "{config_path%*mysqld}"
    for port inports
    do
#      if [ "port" = "3306" ];then
            discover_mysql_json="discover_mysql_json{'cpname':'mysql','port':'port','path':'{config_path%*mysqld}','name':'Mysql组件模板','flag':'pid'},"
#          break;
#      fi
    done    
done
result="[{discover_mysql_json%,*}]"
result=`echo {result//\'/\"}`
echoresult

发表评论

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

Captcha Code