欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

zabbix 监控php-fpm 性能

程序员文章站 2022-06-15 20:01:17
...
首先需要开启php-fpm状态功能


http://www.ttlsa.com/php/use-php-fpm-status-page-detail/

http://www.ttlsa.com/zabbix/zabbix-monitor-php-fpm-status/



vim /usr/local/php/etc/php-fpm.conf


pm.status_path = /status 去掉注释


vim /etc/nginx/vhost/web.conf

server

{

listen 80;

server_name 192.168.80.62;

index index.php index.html index.htm default.html default.htm default.php;

root /usr/local/nginx/html;

location ~ .*\.(php|php5)?$

{

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include /etc/nginx/fastcgi_params;

}


location ~ ^/(status|ping)$ #加上红色部分

{

include fastcgi_params;

fastcgi_pass 127.0.0.1:9000;

fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;

}


location /ngx_status {

stub_status on;

access_log off;

}


location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 12h;

}


access_log off;

}

重启php-fpm


pkill php-fpm

/usr/local/php/sbin/php-fpm


测试如下ok


[root@zabbixserver ~]# curl http://127.0.0.1/status

pool: www

process manager: dynamic

start time: 18/May/2016:07:04:35 +0800

start since: 715765

accepted conn: 21386

listen queue: 0

max listen queue: 1

listen queue len: 128

idle processes: 5

active processes: 1

total processes: 6

max active processes: 6

max children reached: 0

slow requests: 0


zabbix客户端配置key


vim /usr/local/zabbix/etc/zabbix_agentd.conf

UserParameter=php-fpm.status[*],/usr/bin/curl -s "http://127.0.0.1/status?xml" | grep "" | awk -F'>|


killall zabbix_agentd

/usr/local/zabbix/sbin/zabbix_agentd


最后在zabbix-server 导入模板连接模板即可


模板下载地址

zabbix监控php-fpm模板-zabbix 3.x

zabbix监控php-fpm模板-zabbix 2.x