1. 环境

  • php-fpm-exporter.linux.amd64

    php-fpm-exporter 用来收集机器的php 指标


2. 准备条件

2.1 PHP-FPM端

  1. # vim /etc/php-fpm.d/www.conf
  2. pm.status_path = /status
  3. ping.path = /ping
  4. # 重启php-fpm
  5. systemctl restart php-fpm

2.1 Nginx端

  1. # vim /etc/nginx/conf.d/php-fpm-status.conf
  2. server {
  3. listen 9010;
  4. allow 127.0.0.1;
  5. deny all;
  6. location ~ ^/(status|ping)$ {
  7. fastcgi_pass 127.0.0.1:9000;
  8. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  9. include fastcgi_params;
  10. }
  11. }
  12. # 加载配置
  13. systemctl reload nginx

2.3 PHP-FPM-exporter端

一般情况下, php-fpm-exporter 与 php-fpm 在同一个机器上

  1. # 下载php-fpm-exporter --> https://github.com/bakins/php-fpm-exporter/releases
  2. wget https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64 -O /usr/local/src/php-fpm-exporter
  3. chmod +x /usr/local/src/php-fpm-exporter
  4. # 启动 php-fpm-exporter
  5. nohup /usr/local/src/php-fpm-exporter --addr 0.0.0.0:9190 --endpoint http://127.0.0.1:9010/status &> /dev/null &

2.4 Prometheus端

  1. - job_name: php-fpm
  2. static_configs:
  3. - targets: ['<host>:<port>']
  4. labels:
  5. instance: PRODUCT-NAME

2.5 Grafana端

模板地址 https://grafana.com/dashboards/3901