zabbix監控php-fpm的性能

 

zabbix監控php-fpm主要是經過nginx配置php-fpm的狀態輸出頁面,在正則取值php

要nginx能輸出php-fpm的狀態必需要先修改php-fpm的配置,這個配置沒有開啓nginx 就沒有辦法輸出php-fpm statusnginx

修改/usr/local/php/etc/php-fpm.conf 文件vim

注意:不是php.ini,若是沒有配置添加配置bash

pm.status_path = /status
重啓php-fpm
service php-fpm restart
添加nginx的配置
打開/usr/local/nginx/conf/nginx.confphp-fpm

location ~ \.php|^/status$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_connect_timeout 180;
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
include fastcgi.conf;
}

配置好以後重啓一下nginx
service nginx restart測試

添加監控的shlle腳本
php-fpm_status.sh
添加zabbix-agent配置
php-fpm_status.conf
重啓zabbix-agent
service zabbix-agent restart
測試
zabbix_get -s 127.0.0.1 -k slow.requests
若是沒有問題導入模板
php-fpm_status.xml
如今就能看到數據了ui

腳本和模板以下:rest

vim php-fpm_status.sh
#!/bin/bash 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

 

vim php-fpm_status.confUserParameter=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
相關文章
相關標籤/搜索