zabbix监控php-fpm

启用php-fpm status页面

[root@cat ~]# vim /etc/php-fpm.d/www.conf 

pm.status_path = /php_status(将这一行注释去掉)


更改nginx配置文件

worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location /nginx_status {
          stub_status;
          access_log off;
          allow 127.0.0.1;
          allow 192.168.101.0/24; #(zabbix服务器的IP地址,一般是内网地址)
          allow 10.0.0.0/24;
          deny all;
         }
        location / {
            root   html;
            index  index.html index.htm;
        }
       location /php_status {
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      include        fastcgi_params;
      fastcgi_pass   127.0.0.1:9000;
}
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }


    }
}

编译zabbix——agent配置文件

[root@cat ~]# vim /etc/zabbix/zabbix_agentd.d/php_status.conf 

UserParameter=php-fpm.status[*],/usr/bin/curl -s "http://127.0.0.1/php_status?xml" | grep "<$1>" | awk -F'>|<' '{ print $$3}'


重启服务

[root@cat ~]# systemctl restart php-fpm.service 

扫描二维码关注公众号,回复: 1719689 查看本文章

[root@cat ~]# systemctl restart nginx.service 

[root@cat ~]# systemctl restart zabbix-agent.service 

导入模板



猜你喜欢

转载自blog.csdn.net/qq_39583463/article/details/80685605
今日推荐