環境介紹:php
php /usr/loca/phpnginx
nignx /usr/loca/nginx 配置文件都是放在extra中git
修改php-fpm的配置文件啓動狀態頁面github
pm.status_path = /statusweb
配置nginx虛擬主機的配置sql
server { listen 80; server_name localhost; location ~ ^/(status)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; include fastcgi_params; } }
重啓nginx服務shell
[root@localhost ~]# curl http://127.0.0.1/statusvim
pool: www
process manager: dynamic
start time: 26/Jun/2018:18:21:48 +0800 start since: 209 accepted conn: 33 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 1 active processes: 1 total processes: 2 max active processes: 1 max children reached: 0 slow requests: 0
php-fpm status的含義 pool php-fpm pool(資源池)的名稱,大多數狀況下爲www process manager 進程管理方式,現今大多都爲dynamic,不要使用static start time 上次啓動的時間 start since 已運行了多少秒 accepted conn pool 接收到的請求數 listen queue 處於等待狀態中的鏈接數,若是不爲0,須要增長php-fpm進程數 max listen queue 從php-fpm啓動到如今處於等待鏈接的最大數量 listen queue len 處於等待鏈接隊列的套接字大小 idle processes 處於空閒狀態的進程數 active processes 處於活動狀態的進程數 total processess 進程總數 max active process 從php-fpm啓動到如今最多有幾個進程處於活動狀態 max children reached 當php-fpm試圖啓動更多的children進程時,卻達到了進程數的限制,達到一次記錄一次,若是不爲0,須要增長php-fpm pool進程的最大數
建立php_ststus的腳本文件bash
[root@web01 zabbix_agentd.d]# vim php_status.shcurl
listenqueue(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "listen queue:"|grep -vE "len|max"|awk '{print$3}' } listenqueuelen(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "listen queue len" |awk '{print$4}' } idle(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "idle processes" |awk '{print$3}' } active(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "active" |awk '{print$3}'|grep -v "process" } total(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "total processes" |awk '{print$3}' } mactive(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "max active processes:" |awk '{print$4}' } since(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "start since: " |awk '{print$3}' } conn(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "accepted conn" |awk '{print$3}' } reached(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "max children reached" |awk '{print$4}' } requests(){ wget --quiet -O - http://127.0.0.1:80/status?auto |grep "slow requests" |awk '{print$3}' } $1
編輯自配置文件
UserParameter=idle.processe,
/scripts/php-fpm_status
.sh idle
UserParameter=total.processes,
/scripts/php-fpm_status
.sh total
UserParameter=active.processes,
/scripts/php-fpm_status
.sh active
UserParameter=max.active.processes,
/scripts/php-fpm_status
.sh mactive
UserParameter=listen.queue.len,
/scripts/php-fpm_status
.sh listenqueuelen
UserParameter=listen.queue,
/scripts/php-fpm_status
.sh listenqueue
UserParameter=start.since,
/scripts/php-fpm_status
.sh since
UserParameter=accepted.conn,
/scripts/php-fpm_status
.sh conn
UserParameter=max.children.reached,
/scripts/php-fpm_status
.sh reached
UserParameter=slow.requests,
/scripts/php-fpm_status
.sh requests