Zabbix主被动监控
一、概述
zabbix服务有2种工作模式:主动模式 被动模式(默认)
- 主动和被动都是对被监控端主机而言的
- 默认Zabbix采用的是被动监控
- 被动监控:Server向Agent发起连接,发送监控key,Agent接受请求,相应监控数据。
- 主动监控:Agent向Server发起连接,Agent请求需要检测的监控项目列表,Server响应Agent发送一个Items列表,Agent确认收到监控列表,TCP连接完成,会话关闭,Agent开始周期性的手机数据
- 区别
- Server不用每次需要数据都连接Agent,Agent会自己收集数据并处理,Server仅需要保存数据即可。
- 当监控主机达到一定量级后,Zabbix服务器会越来越慢
- 使用主动监控,释放服务器压力
- Zabbix也支持分布式监控。
二、主动监控方式
以192.168.2.101为例
2.1、安装软件
[root@host101 ~]# yum -y install gcc pcre-devel
[root@host101 ~]# tar -zxf zabbix-3.4.4.tar.gz
[root@host101 ~]# cd zabbix-3.4.4/
[root@host101 zabbix-3.4.4]# ./configure --enable-agent
[root@host101 zabbix-3.4.4]# make install
[root@host101 ~]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_agentd.conf.d
[root@host101 ~]# ls /usr/local/sbin/
zabbix_agentd
[root@host101 ~]# ls /usr/local/bin/
zabbix_get zabbix_sender
2.2、修改配置文件
设置zabbix_agentd服务工作模式为主动模式
[root@host101 ~]# vim /usr/local/etc/zabbix_agentd.conf
145 Hostname=host101
93 #Server=127.0.0.1 //注释掉
134 ServerActive=192.168.2.5:10051
118 StartAgents=0
183 RefreshActiveChecks=120
30 LogFile=/tmp/zabbix_agentd.log
2.3、启动服务
[root@host101 ~]# useradd zabbix
[root@host101 ~]# zabbix_agentd
[root@host101 ~]# netstat -utnlp | grep 10050
//只有进程没有端口
[root@host101 ~]# ps -C zabbix_agentd
PID TTY TIME CMD
9111 ? 00:00:00 zabbix_agentd
9112 ? 00:00:00 zabbix_agentd
9113 ? 00:00:00 zabbix_agentd
三、在web 页面创建主动模式的模板
3.1、克隆模板
其他全部默认,选择添加
3.2、修改监控项模式
全部选择
选择批量更新
修改类型为主动式,完成后页面下方点击更新
还有三项无法变为主动模式,关闭即可
3.3、添加主机
主机名称必须和配置文件中的一样
IP地址可以使用0.0.0.0占位,不能为空,添加完成后选择模板