网站首页 > 技术教程 正文
利用php-fpm-exporter对php-fpm进行监控
- 1、php-fpm开启status接口
- 2、nginx代理php-fpm接口
- 3、使用php-fpm-exporter暴露指标给Prometheus
- 4、granfna展示
一、 php-fpm 开启status接口
需要提前安装好php,和nginx 环境
- 1、 找到php配置文件,修改配置,开启status vim /usr/local/php/etc/php-fpm.conf
...
pm.status_path = /status
ping.path = /ping
...
- 2、 配置nginx
server {
listen 9010;
allow 127.0.0.1;
deny all;
location ~ ^/(status|ping)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
- 3、检查status是否可以访问
[root@Prometheus conf]# curl http://127.0.0.1:9010/status
pool: www
process manager: dynamic
start time: 23/Feb/2020:11:54:50 +0800
start since: 10626
accepted conn: 1
listen queue: 0
max listen queue: 0
listen queue len: 128
idle processes: 14
active processes: 1
total processes: 15
max active processes: 1
max children reached: 0
slow requests: 0
二、 使用php-fpm-exporter暴露指标
- 1、下载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/exporter/php-fpm/
mv php-fpm-exporter.linux.amd64 /usr/local/exporter/php-fpm/php-fpm-exporter
nohup /usr/local/exporter/php-fpm/php-fpm-exporter --addr 0.0.0.0:9190 --endpoint http://127.0.0.1:9010/status &
- 2、检查metrics是否可以访问
[root@Prometheus php-fpm]# 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 4
# 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 128
# 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"} 14
# 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
- web 访问
三、配置promethus,采集php-fpm的数据
vim /usr/local/promethus/promethus.yml
- job_name: 'php-fpm'
static_configs:
- targets:
- 114.67.116.119:9190
四、配置granfna进行数据展示
配置导入,3901模板
猜你喜欢
- 2024-10-11 浅谈从PHP迁移至Golang(基础篇)(php传值到另一个php)
- 2024-10-11 相同逻辑的php与golang代码效率对比,最好语言落谁家…
- 2024-09-21 蓝易云 - 在centos中配置nginx+php的环境教程。
- 2024-09-21 Zabbix运维—监控php-fpm、redis服务
- 2024-09-21 Zabbix 5.2由浅入深之监控php-fpm
- 2024-09-21 PHP-FPM实现性能优化的方法(php-fpm 优化)
- 2024-09-21 PHP-FPM高负载的解决办法(php高负载解决方案)
- 2024-09-21 php-fpm的配置和优化(php-fpm调优)
- 2024-09-21 docker中运行php文件(docker php fpm)
- 2024-09-21 php-fpm优化(php-fpm性能优化)
你 发表评论:
欢迎- 最近发表
-
- Linux新手必看:几种方法帮你查看CPU核心数量
- linux基础命令之lscpu命令(linux中ls命令的用法)
- Linux lscpu 命令使用详解(linux常用ls命令)
- 如何查询 Linux 中 CPU 的数量?这几个命令要知道!
- 在linux上怎么查看cpu信息(linux如何查看cpu信息)
- 查看 CPU 的命令和磁盘 IO 的命令
- 如何在CentOS7上改变网卡名(centos怎么改网卡名字)
- 网工必备Linux网络管理命令(网工必备linux网络管理命令是什么)
- Linux 网络命令知多少(linux 网络 命令)
- Linux通过命令行连接wifi的方式(linux命令行连接无线网)
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)