百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>服务器> linux中Zabbix监控PHP-FPM的配置
分享文章到:

linux中Zabbix监控PHP-FPM的配置

发布时间:01/15 来源: 浏览: 关键词:
监控PHP-FPM可以帮助到我们实时监控PHP-FPM服务器环境的运行状态了,下面我们来看一篇关于linux中Zabbix监控PHP-FPM的配置详解吧,具体的如下文介绍。

安装lnmp环境,安装zabbix-agent端

yum install php-fpm nginx mysql mysql-server
wget http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm
yum install zabbix-agent-2.4.7 zabbix-sender-2.4.7 zabbix-2.4.7

1,php在5.3.3后就集成了php-fpm模块,打开此项

[root@localhost ~]# cat /etc/php-fpm.d/www.conf |grep pm.status
pm.status_path = /status

2,将status include

[root@localhost nginx]# cat nginx.conf
user              nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    include /etc/nginx/conf.d/*.conf;
}

3,status.conf

[root@localhost conf.d]# cat php-status.conf
server {
    listen  *:80 default_server;
    server_name _;
    location ~ ^/(status|ping)$
    {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    }
}

4,测试

[root@localhost conf.d]# curl 192.168.158.130/status
pool:                 www
process manager:      dynamic
start time:           21/May/2016:07:42:59 -0700
start since:          29
accepted conn:        68
listen queue:         0
max listen queue:     0
listen queue len:     128
idle processes:       4
active processes:     1
total processes:      5
max active processes: 1
max children reached: 0
[root@localhost conf.d]#

5,添加key

vim /etc/zabbix/zabbix_agentd.conf
UserParameter=php-fpm.status[*],/usr/bin/curl -s "http://127.0.0.1/status?xml" | grep "<$1>" | awk -F'>|<' '{ print $$3}'
开启slow

[root@localhost php-fpm.d]# cat www.conf |grep slowlog|egrep -v "^;"
request_slowlog_timeout = 3
slowlog = /var/log/php-fpm/www-slow.log
[root@localhost php-fpm.d]# pwd
/etc/php-fpm.d
[root@localhost php-fpm.d]#

6,导入模板

http://pan.baidu.com/share/init?shareid=1795643884&uk=1074693321

密码:9z8z

7

full详解
pid –进程PID,可以单独kill这个进程. You can use this PID to kill a long running process.
state –当前进程的状态 (Idle, Running, …)
start time –进程启动的日期
start since –当前进程运行时长
requests –当前进程处理了多少个请求
request duration– 请求时长(微妙)
request method –请求方法 (GET, POST, …)
request URI –请求URI
content length –请求内容长度 (仅用于 POST)
user –用户 (PHP_AUTH_USER) (or ‘-’ 如果没设置)
script – PHP脚本 (or ‘-’ if not set)
last request cpu – 最后一个请求CPU使用率。
last request memorythe -上一个请求使用的内存
php-fpm status详解
pool –fpm池子名称,大多数为www
process manager– 进程管理方式,值:static, dynamic or ondemand. dynamic
start time– 启动日期,如果reload了php-fpm,时间会更新
start since – 运行时长
accepted conn– 当前池子接受的请求数
listen queue – 请求等待队列,如果这个值不为0,那么要增加FPM的进程数量
max listen queue– 请求等待队列最高的数量
listen queue len – socket等待队列长度
idle processes – 空闲进程数量
active processes – 活跃进程数量
total processes– 总进程数量
max active processes – 最大的活跃进程数量(FPM启动开始算)
max children reached - 大道进程最大数量限制的次数,如果这个数量不为0,那说明你的最大进程数量太小了,请改大一点

8,出图如下:

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有8人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板