龙空技术网

Promethues如何监控PHP

运维攻城狮 650

前言:

眼前你们对“摄像头监控php”大概比较关心,咱们都需要剖析一些“摄像头监控php”的相关知识。那么小编在网摘上收集了一些有关“摄像头监控php””的相关资讯,希望姐妹们能喜欢,看官们一起来学习一下吧!

利用php-fpm-exporter对php-fpm进行监控1、php-fpm开启status接口2、nginx代理php-fpm接口3、使用php-fpm-exporter暴露指标给Prometheus4、granfna展示一、 php-fpm 开启status接口

需要提前安装好php,和nginx 环境

1、 找到php配置文件,修改配置,开启status vim /usr/local/php/etc/php-fpm.conf

...pm.status_path = /statusping.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 :                 wwwprocess manager:      dynamicstart time:           23/Feb/2020:11:54:50 +0800start since:          10626accepted conn:        1listen queue:         0max listen queue:     0listen queue len:     128idle processes:       14active processes:     1total processes:      15max active processes: 1max children reached: 0slow requests:        0
二、 使用php-fpm-exporter暴露指标1、下载php-fpm-exporter,并启动
wget  -p /usr/local/exporter/php-fpm/mv php-fpm-exporter.linux.amd64 /usr/local/exporter/php-fpm/php-fpm-exporternohup /usr/local/exporter/php-fpm/php-fpm-exporter --addr 0.0.0.0:9190 --endpoint  &
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 counterphpfpm_accepted_connections_total 4# HELP phpfpm_active_max_processes Maximum active process count# TYPE phpfpm_active_max_processes counterphpfpm_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 gaugephpfpm_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 gaugephpfpm_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 counterphpfpm_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 counterphpfpm_max_children_reached_total 0# HELP phpfpm_processes_total process count# TYPE phpfpm_processes_total gaugephpfpm_processes_total{state="active"} 1phpfpm_processes_total{state="idle"} 14# HELP phpfpm_scrape_failures_total Number of errors while scraping php_fpm# TYPE phpfpm_scrape_failures_total counterphpfpm_scrape_failures_total 0# HELP phpfpm_slow_requests_total Number of requests that exceed request_slowlog_timeout# TYPE phpfpm_slow_requests_total counterphpfpm_slow_requests_total 0# HELP phpfpm_up able to contact php-fpm# TYPE phpfpm_up gaugephpfpm_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模板

标签: #摄像头监控php #phplisten #php54环境