安装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,出图如下: