分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

zabbix监控nginx和php

发布时间:2023-09-06 01:39责任编辑:熊小新关键词:nginx
创建zabbix_agentd的子配置文件
在/usr/local/zabbix/etc/zabbix_agentd.d/中创建关联nginx status和php-fpm status的子配置文件,创建一个,或者在已有的某配置文件中增加也可以,我这里分别为它们创建配置文件,文件名可自定义,只要确保此文件夹全部内容在zabbix_agentd.conf中包含(include)了。

  1. userparameter_nginx.conf
    [root@monitor-server2 zabbix_agentd.conf.d]# cat userparameter_nginx.conf
    #/usr/local/zabbix/bin/nginx_status.sh
    UserParameter=nginx.status[*],/usr/local/zabbix/bin/nginx_status.sh $1 ?
    #这种写法比较简洁,参考zabbix 3.2.4中自带的的userparameter_examples.conf
    UserParameter=nginx.version,/usr/local/nginx/sbin/nginx -v ????
    #让zabbix-agentd获取nginx的版本信息 ,一切shell指令都推荐使用绝对路径
  2. userparameter_php-fpm.conf
    [root@monitor-server2 zabbix_agentd.conf.d]# cat userparameter_php-fpm.conf
    #/usr/local/zabbix/bin/php_fpm_status.sh
    UserParameter=php-fpm.status[*],/usr/local/zabbix/bin/php_fpm_status.sh $1
    UserParameter=php-fpm.version,/usr/local/php/sbin/php-fpm -v | awk ‘NR==1{print $0}‘ ??
    #获取php-fpm版本信息
  3. 确认子配置文件被zabbix_agentd配置文件包含
    确认在/usr/local/zabbix/etc/zabbix_agentd.conf中包含:Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/且没有被注释。

zabbix-agent配置自定义key:
UserParameter=nginx.status[],/etc/zabbix/scripts/nginx_status.sh $1
UserParameter=php-fpm.status[
],/usr/bin/curl -s -m 5 "http://127.0.0.1/statusx45?xml" | grep "<$1>" | awk -F‘>|<‘ ‘{ print $$3}‘
#UserParameter=idle.processe,/etc/zabbix/scripts/php-fpm_status.sh idle
#UserParameter=total.processes,/etc/zabbix/scripts/php-fpm_status.sh total
#UserParameter=active.processes,/etc/zabbix/scripts/php-fpm_status.sh active
#UserParameter=max.active.processes,/etc/zabbix/scripts/php-fpm_status.sh mactive
#UserParameter=listen.queue.len,/etc/zabbix/scripts/php-fpm_status.sh listenqueuelen
#UserParameter=listen.queue,/etc/zabbix/scripts/php-fpm_status.sh listenqueue
#UserParameter=start.since,/etc/zabbix/scripts/php-fpm_status.sh since
#UserParameter=accepted.conn,/etc/zabbix/scripts/php-fpm_status.sh conn
#UserParameter=max.children.reached,/etc/zabbix/scripts/php-fpm_status.sh reached
#UserParameter=slow.requests,/etc/zabbix/scripts/php-fpm_status.sh requests
UserParameter=chatter.pid[*],ps -ef | grep $1 | grep -v grep | grep $2 | grep -v grep | awk ‘{print $$2}‘

zabbix服务端的get数值
[root@mha ~]# zabbix_get ?-s 192.168.198.131 ?-k ?‘nginx.status[ping]‘
1

zabbix页面:
nginx:
添加nginx status监控模板

新建nginx status模板

定义nginx status模板

新建nginxApplication

定义nginx status items,这里我使用的是被动临控

增加nginx status状态码映射

nginx trigger定义

定义nginx监控视图

zabbix监控nginx和php

原文地址:http://blog.51cto.com/wsw26/2064990

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved