#!/bin/bash
#2019-7-1 15:12:06
#by author 、、、小柒
#Zabbix监控php-fpm性能以及进程状态

HOST="https://www.yangxingzhen.com"

if [ $# -eq 0 ];then
	echo -e "\033[32m Usage:/bin/bash|sh $0 ping|active|idle|total|max\033[0m"        
	exit 1
fi

function ping {
	/sbin/pidof php-fpm | wc -l
}

function active {
	curl -s "${HOST}/php_fpm_status" |awk '/^active/ {print $NF}'
}

function idle {
	curl -s "${HOST}/php_fpm_status" |awk '/idle/ {print $NF}'
}

function total {
	curl -s "${HOST}/php_fpm_status" |awk '/total/ {print $NF}'
}

function max {
	curl -s "${HOST}/php_fpm_status" |awk '/max active/ {print $NF}'
}

$1
