zabbix 5.0 监控nginx docker redis php-fpm 网络设备——筑梦之路
2023-09-14 09:09:36 时间
zabbix 5.0 新增加了许多模板,我们可以利用自带的模板对某些应用服务或网络设备进行监控。
监控nginx:
nginx配置文件添加如下:
location /status { #定义运行状态页面名称,页面为status
stub_status on; #开启模块
access_log off; #不开启访问日志记录
allow 127.0.0.1; #运行127.0.0.1地址访问此网页
allow 192.168.25.0/24; #只运行192.168.25.0网段的主机访问此网页
deny all; #其余网段主机不允许访问
}
需要注意的是nginx需要开启模块:--with-http_stub_status_module
发送请求:curl http://192.168.25.42:8090/status 必须有数据返回
监控apache:
新建配置文件:
/etc/httpd/conf.d/info.conf
<Location /server-status>
SetHandler server-status
Order allow,deny
Allow from localhost
Allow from 192.168.25.0/24
</Location>
ExtendedStatus On
需要注意的是,此方法是使用apache 服务的status模块
请求:curl http://192.168.25.42:8000/server-status?auto 必须有数据返回
监控redis:
zabbix 5.0 zabbix-agent2 已经内置监控redis的接口
修改redis配置:
bind 0.0.0.0
这个地方必须要改,不然zabbix-server不在同一机器上采集不到数据
zabbix-agent2 也必须安装,配置好zabbix-server信息
redis无密码的情况下直接使用模板进行关联
redis有密码的情况下需要添加宏值:$REDIS_PASS}
此处可参考:https://blog.csdn.net/hority/article/details/106415073
监控ntp服务:
zabbix 5.0 监控ntp服务,首先需要搭建ntpd服务
服务端:(ntp方式)
/etc/ntp.conf
#restrict default nomodify notrap nopeer noquery
restrict 192.168.25.42 nomodify notrap nopeer noquery
restrict 192.168.25.0 mask 255.255.252.0 nomodify notrap
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
客户端:(ntp方式)
/etc/ntp.conf
server 192.168.25.42
测试检验:
ntpd -p
ntpdate -q 192.168.25.42
--------------------------------------------------------
服务端:(chrony方式)
/etc/chrony.conf
server 0.centos.pool.ntp.org iburst #可以修改ntp的服务器。最好用国内的。
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
allow 192.168.25.0/24 #打开允许同步的IP
阿里的时间服务器:
time1.aliyun.com
time2.aliyun.com
time3.aliyun.com
time4.aliyun.com
time5.aliyun.com
time6.aliyun.com
time7.aliyun.com
chronyc sources
客户端:(chrony方式)
#server 0.centos.pool.ntp.org iburst #注释此处
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 192.168.25.42 iburst #添加server
验证:date
chronyc sources
监控ntp时间服务进程,直接关联模板即可
监控docker:
zabbix 5.0 监控docker 需要使用zabbix-agent2
将zabbix添加到docker组:
usermod -aG docker zabbix
这里不加的话,用户权限存在问题
web上直接关联模板即可
自动发现监控docker,更加深入的使用参考如下:
https://blog.csdn.net/bbwangj/article/details/80785349
监控php-fpm:
修改php-fpm配置www.conf
pm.status_path = /php-fpm-status
ping.path = /php-fpm-ping
修改nginx配置:
location ~ ^/php-fpm-(status|ping)$ {
access_log off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass unix:/usr/local/php-fastcgi/var/run/php-fpm.sock;
allow 127.0.0.1;
deny all;
}
测试:
curl http://127.0.0.1/php-fpm-ping
curl http://127.0.0.1/php-fpm-status
在Zabbix前端页面,点击“Configuration” -> “Templates”,找到名称为“Template App PHP-FPM by Zabbix agent”的模板。
该模板定义了几个重要的参数:
{$PHP_FPM.HOST}:PHP-FPM状态的Nginx主机名或IP地址,默认是“localhost”;
{$PHP_FPM.PING.PAGE}:PHP-FPM ping状态页面地址,默认是“ping”,这里是“php-fpm-ping”,
{$PHP_FPM.PING.REPLY}:PHP-FPM ping的返回值,默认是“pong”;
{$PHP_FPM.PORT}:PHP-FPM状态的Nginx主机的端口号,默认值是“80”;
{$PHP_FPM.STATUS.PAGE}:PHP-FPM状态页面地址,默认值是“status”,这里是”php-fpm-status“。
监控网络设备,使用snmp协议,前提是需要交换机、路由器、打印机这些设备开启了snmp协议,并记录下版本和ip地址,然后在web上直接关联模板即可
相关文章
- Docker安装Kafka(docker-compose)、EFAK监控
- 借助监控实现Redis性能优化(监控redis性能)
- 测试Java操作Redis实例(java测试redis)
- 如何实现 Redis 的多连接管理?(redis多连接)
- 开源挑战实时监控Redis状态(开源redis监控)
- 状态使用监控系统监控Redis缓存服务状态(监控redis缓存服务)
- 监控Redis队列变化实现实时分析(监听redis队列变化)
- 深入Redis查看连接数的实时监控(查看redis连接数数量)
- 服务如何顺利卸载并关闭Redis服务(卸载redis关闭)
- 利用Redis提升活动实时统计监控能力(利用redis做统计监控)
- 分布式系统的实时Redis监控(分布式系统redis监听)
- 实现更高效率Redis双表技术(双表的redis数据库)
- 探讨Redis的默认存储位置(redis 默认存储位置)
- Redis集群锁的失效性质研究(redis集群锁失效)
- 如何搭建及运用Redis集群(redis集群如何使用)
- 支持Redis集群实现多数据库的灵活支持(redis集群 多数据库)
- Redis配置深度剖析(redis配置详细介绍)
- 快速了解Redis配置5步快速掌握(redis配置步骤)
- Redis与哪个框架的整合之路(redis跟哪个框架整和)
- 监控Redis设备实时在线监控(redis 设备在线)
- Redis性能优化快速高效的正确配置方法(redis配置性能优化)