linux中Zabbix監控PHP-FPM的配置

來源:互聯網
上載者:User

安裝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,出圖如下:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.