首页 > 编程语言 >Prometheus php-fpm监控安装部署

Prometheus php-fpm监控安装部署

时间:2023-05-13 18:01:18浏览次数:50  
标签:status exporter log fpm Prometheus php fastcgi

1.进入默认php配置文件:/etc/php/7.3/fpm/php-fpm.conf 添加:pm.status_path = /fpm_status

echo "pm.status_path = /fpm_status" >>/etc/php/7.3/fpm/php-fpm.conf 

2.在nginx配置文件下面添加fpm-status location配置:/etc/nginx/conf.d/nginx-php.conf

    location ~ ^/(fpm_status|health)$ {
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

systemctl restart php7.3-fpm

systemctl reload nginx

测试一下:curl http://localhost:9090/fpm_status 有数据就ok

安装这个文件: php-fpm-exporter.linux.amd64 (官网地址:https://github.com/bakins/php-fpm-exporter/releases)

安装好了 :

mkdir /usr/local/php-fpm-exporter/
scp [email protected]:~/php-fpm-exporter /usr/local/php-fpm-exporter/
cd /usr/local/php-fpm-exporter/
chmod +x  php-fpm-exporter
nohup ./php-fpm-exporter --addr="172.0.100.49:9190" --endpoint="http://172.0.100.49:9090/fpm_status" >nohup.out 2>&1 &

netstat -ntpl |grep 

测试:curl 172.0.100.49:9190/metrics(也可以不用测试)

nohup /usr/local/php-fpm-exporter/php-fpm-exporter --addr="`ip a|grep global|awk -F'[ ]+|/' '{print $3}'`:9190" --endpoint="http://`ip a|grep global|awk -F'[ ]+|/' '{print \$3}'`:9090/fpm_status" >/usr/local/php-fpm-exporter/nohup.out 2>&1 &
server {
    listen       9090 backlog=8192;
    server_name  172.0.100.33;
    root   /data/qcnft_php/public;
    access_log  /data/log/nginx/qcsc_access.log  log_json;
    error_log /data/log/nginx/qcsc_error.log;

    keepalive_timeout 60s;
    
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";
    
    index index.html index.htm index.php;
    
    charset utf-8;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string; 
    }
      
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    
    error_page 404 /index.php;
    
    location ~ /\.(?!well-known).* {
        deny all;
    }
    
    location = /nginx_status {
    	stub_status on;
    access_log off;
    }


    location ~ \.php$ {
        fastcgi_pass   unix:/run/php/php-fpm.sock;
        fastcgi_index  index.php;
    fastcgi_read_timeout 150;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~ /\.(?!well-known).* {
        deny all;
    }
    location ~ ^/(fpm_status|health)$ {
        fastcgi_pass unix:/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}

标签:status,exporter,log,fpm,Prometheus,php,fastcgi
From: https://www.cnblogs.com/mchbook/p/17397837.html

相关文章

  • 用扩展的方式在 PHP 中使用 Kafka
    前言:    由于之前在PHP中使用Kafka是通过composer包的方式,由于 nmred/kafka-php很久没有维护,并且网上相关问题的文章也比较少。所以我这次换成PHP扩展 RdKafka继续使用,主要介绍扩展安装和这种方式的基本操作。 安装:1.下载2.目录    由于php-rdkafka......
  • 如何在业务代码中使用 ThinkPHP5.1 封装的容器内反射方法
    invokeClass用法:可以不传命名空间实例化(通过反射实例化)$obj=Container::getInstance()->invokeClass(InvokerTest::class);var_dump($obj->invokerNews());die;-----------------------------------------------------------------------invokeMethod用法:传入带命名空间的类和......
  • PHP对接ESP8266
    前言:    众所周知,在APP开发中,C/S是基本的开发结构。客户端负责应用的展示,交互与网络请求,服务端负责数据的传输,处理,存储,输出等等。而物联网除了之前介绍的MQTT实现H5实时控制舵机旋转角度来完成开关外,同样也可以通过HTTP的请求方式来和任何一门语言的服务端进行交互。  ......
  • 正确使用php开发系列:判断数组的key是否存在
    背景:我们习惯上使用!empty($data['data']['list']判断数组$data里有没有key为list的元素,正确判断key是否存在的方式应该使用array_key_exists 为什么不要使用!empty($data['data']['list'],因为当list不存在时,会报错!......
  • PHP发送文件到JAVA项目
    https://blog.csdn.net/u012685554/article/details/126995307亲测有用。php代码$file=$_FILES['order_upload']['tmp_name'];////var_dump($file);exit();////判断文件是否存在if(!file_exists($file)){......
  • php imagick圆角
    $watermark=new\Imagick();$watermark->readImage($avatarpath);$watermark->scaleImage(160,160,true);$watermark->setFormat('png');$mask=new\Imagick();$mask->newImage($watermark......
  • 浅谈一下ThinkPHP5.1实现事务嵌套的特性
    前言:       在我们平时做的一个项目中,线上环境突然发现数据库被锁住。导致很多有关数据插入和修改的接口全都瘫痪,项目基于ThinkPHP5.1。报错的时候,我们发现了一条sql错误日志,如下。   根据错误信息提示,是说有一个事务回滚时没有找到savepoint的暂存点。所以问题应该......
  • php 异步形式调取导出数据
    php部分ajax请求此部分functionaysncexec(){$lock_file='filelock.lock';if(file_exists($lock_file)){exit(json_encode(array('code'=>0)));}$url=base_url().'execcmd';......
  • php获取目录下所有文件及目录
    来源:http://www.shanhubei.com/archives/2614.htmlhttp://www.shanhubei.com/archives/1940.html获取某目录下所有子文件和子目录functiongetDirContent($path){if(!is_dir($path)){returnfalse;}//readdir方法/*$dir=opendir($path);......
  • mysql:安装phpmyadmin(phpMyAdmin 5.2.1 / PHP 8.2.5 / mysqld 8.0.33)
    一,下载phpmyadmin:官网:https://www.phpmyadmin.net/如图: 注意不同版本的环境需求可以得到下载地址后直接在linux上wget[root@imgphpmyadmin]#wgethttps://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.zip解压:[root@imgphpmyadm......