• 欢迎来到小爱博客,一个分享互联网IT技术的网站,喜欢就收藏吧!

prometheus监控php-fpm

grafana 小爱 2个月前 (08-14) 41次浏览 已收录 0个评论 扫描二维码

php-fpm监控

php-fpm配置

$ vim /etc/php-fpm.d/www.conf
pm.status_path = /status
ping.path = /ping

$ systemctl restart php-fpm

nginx配置

$ vim /usr/local/nginx/conf/vhost/php-fpm-status.conf
server {
    listen 9010; 

    location ~ ^/(status|ping)$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        allow 127.0.0.1;
        allow 172.31.217.169;
        deny all;
    }
}


$ systemctl reload nginx

$ curl 127.0.0.1:9010/status
pool:                 www
process manager:      dynamic
start time:           11/Dec/2019:15:32:48 +0800
start since:          374
accepted conn:        1
listen queue:         0
max listen queue:     0
listen queue len:     511
idle processes:       4
active processes:     1
total processes:      5
max active processes: 1
max children reached: 0
slow requests:        0

php-fpm-exporter配置

$ wget https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64
$ mv php-fpm-exporter.linux.amd64 /usr/local/node_exporter/php-fpm-exporter

$ chmod +x  /usr/local/node_exporter/php-fpm-exporter
$ cd /tmp; nohup /usr/local/node_exporter/php-fpm-exporter --addr 0.0.0.0:9190 --endpoint http://127.0.0.1:9010/status &> /dev/null &

$ curl 127.0.0.1:9190/metrics
# HELP phpfpm_accepted_connections_total Total number of accepted connections
# TYPE phpfpm_accepted_connections_total counter
phpfpm_accepted_connections_total 5
# HELP phpfpm_active_max_processes Maximum active process count
# TYPE phpfpm_active_max_processes counter
phpfpm_active_max_processes 1
# HELP phpfpm_listen_queue_connections Number of connections that have been initiated but not yet accepted
# TYPE phpfpm_listen_queue_connections gauge
phpfpm_listen_queue_connections 0
# HELP phpfpm_listen_queue_length_connections The length of the socket queue, dictating maximum number of pending connections
# TYPE phpfpm_listen_queue_length_connections gauge
phpfpm_listen_queue_length_connections 511
# HELP phpfpm_listen_queue_max_connections Max number of connections the listen queue has reached since FPM start
# TYPE phpfpm_listen_queue_max_connections counter
phpfpm_listen_queue_max_connections 0
# HELP phpfpm_max_children_reached_total Number of times the process limit has been reached
# TYPE phpfpm_max_children_reached_total counter
phpfpm_max_children_reached_total 0
# HELP phpfpm_processes_total process count
# TYPE phpfpm_processes_total gauge
phpfpm_processes_total{state="active"} 1
phpfpm_processes_total{state="idle"} 5
# HELP phpfpm_scrape_failures_total Number of errors while scraping php_fpm
# TYPE phpfpm_scrape_failures_total counter
phpfpm_scrape_failures_total 0
# HELP phpfpm_slow_requests_total Number of requests that exceed request_slowlog_timeout
# TYPE phpfpm_slow_requests_total counter
phpfpm_slow_requests_total 0
# HELP phpfpm_up able to contact php-fpm
# TYPE phpfpm_up gauge
phpfpm_up 1

Prometheus配置

$ vim /usr/local/prometheus/prometheus.yml 
......
  - job_name: 'php-fpm'
    static_configs:
    - targets:
      - 172.31.217.169:9190
      
$ kill -hup `ps -ef |grep prometheus|grep -v grep|awk '{print $2}'`

到Prometheus中查看Targets是否正常

image

查看是否正常采集到的数据

image

grafana配置


小爱博客 , 版权所有
转载请注明原文链接:prometheus监控php-fpm
喜欢 (0)
【你的支持, 我的动力】
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址