5fc996e8765984799.jpg_fo742.png

#!/bin/bash

export LANG=en_US.UTF-8

discover_php_json=""
#pid=`ps aux|grep php-fpm|grep -v grep|grep -v ps|grep master| head -n 1|awk '{print $2}'`
bin_file=`whereis php-fpm|awk '{print $2}'`
if [[ "" != $bin_file ]];then
    bin_path=`dirname $bin_file`
    #port=`netstat -lnp | grep $pid/php-fpm | grep -v grep | head -1 | awk '{print $4}' | awk -F ':' '{print $NF}'`
    port=$(grep "listen = " /etc/php-fpm.d/www.conf|grep -v '^$|#'|awk -F '=' '{print $2}' | awk -F ':' '{print $2}')
    pid=$(netstat -lnp | grep -w $port  |awk '{print $NF}' | awk -F '/' '{print $1}'|head -n 1)

    cd $bin_path
    pwd=`pwd /`
    if [[ $pid != "" ]];then
        discover_php_json="[{'cpname':'php-fpm','port':$port,'path':'$pwd','name':'PHP-FPM组件模板','flag':'$pid'}]"
    else
        discover_php_json="[]"
    fi
else
    discover_php_json="[]"
fi
result=$discover_php_json
result=`echo ${result//\'/\"}`
echo $result

发表评论

您的电子邮箱地址不会被公开。

Captcha Code