监控PHP-FPM状态

grafana-prometheus-php-fpm

公司新项目需要增加PHP服务器的监控,所以自己百度搞了一套,整理一下,记录下来,利用php-fpm自带的状态页实现。

nginx

需要配置nginx.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;
        }
}

通过NGINX去定向解析php-fpm的状态页。

PHP-FPM

找到php-fpm所在的配置文件www.conf 添加内容如下

pm.status_path = /status
ping.path = /ping

重启php-fpm

systemctl restart php-fpm

PHP-FPM-EXPORTER

下载与prometheus搭配使用的php-fpm-exporter

  • 下载地址
wget https://github.com/bakins/php-fpm-exporter/releases/download/v0.6.1/php-fpm-exporter.linux.amd64
  • 部署
mkdir -p /usr/local/prometheus
mv ./php-fpm-exporter.linux.amd64 /usr/local/prometheus
chown +x /usr/local/prometheus/php-fpm-exporter.linux.amd64
  • 启动
nohup ./php-fpm-exporter.linux.amd64 --addr 127.0.0.1:9190 --endpoint http://127.0.0.1:9010/stauts  > /var/logs/proemthues.log 2>&1 &

配置promethues

找到启动promethues的配置文件promethues.yml
修改内容如下

- job_name: 'PHP-FPM'
    static_configs:
      - targets:
        - 127.0.0.1:9190

重启promethues

systemctl restart promethues.server
  • 查看配置的状态

在这里插入图片描述
State Up OK

grafana配置图表

推荐图表地址
https://grafana.com/dashboards/3901php-fpm图表
直接import 导入 3901
在这里插入图片描述
完成!
友情链接:

  1. grafana图表地址:https://grafana.com/grafana/dashboards?dataSource=prometheus
  2. promethues扩展地址:https://prometheus.io/download/
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值