1. 监控主机的添加
(1)手动添加监控主机
目的:手动添加主机server2
首先先在server2上进行设置:
(1) 配置yum仓库,下载zabbix-agent,并修改代理配置文件
[root@server1 yum.repos.d]# ls
redhat.repo westos.repo zabbix.repo
[root@server1 yum.repos.d]# scp zabbix.repo [email protected]:/etc/yum.repos.d
The authenticity of host '172.25.33.2 (172.25.33.2)' can't be established.
ECDSA key fingerprint is 75:95:da:07:65:8f:01:97:87:e0:3f:cc:bc:85:44:a6.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.25.33.2' (ECDSA) to the list of known hosts.
[email protected]'s password:
zabbix.repo 100% 61 0.1KB/s 00:00
[root@server2 yum.repos.d]# yum install zabbix-agent -y ##下载代理端
[root@server2 yum.repos.d]# cd /etc/zabbix/
[root@server2 zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d
[root@server2 zabbix]# vim zabbix_agentd.conf ##修改代理的监控配置文件
98 Server=172.25.33.1 #被动发现服务器ip
139 ServerActive=172.25.33.1 #主动发现服务器ip
150 Hostname=server2 #主机名,因为已经做过解析
[root@server2 zabbix]# systemctl start zabbix-agent
[root@server2 zabbix]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@server2 zabbix]# netstat -antlp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 835/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 885/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 10680/zabbix_agentd
tcp 0 0 172.25.4.2:22 172.25.4.250:39000 ESTABLISHED 1205/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 835/sshd
tcp6 0 0 ::1:25 :::* LISTEN 885/master
tcp6 0 0 :::10050 :::* LISTEN 10680/zabbix_agentd
其次:
在监控页面中选择配置-->主机-->创建主机
主机名称:server2
群组:linux servers
Ip地址:172.25.33.2
然后点击模板,选择template 0s linux
最后点击添加
可以在主机中看到server2已经添加成功
手动添加时会存在一定的弊端,当代理端数量较多时,则手动添加比较困难,我们可以采用自动发现以及自动注册
(2)自动发现监控主机(针对大批量主机 有相同特性)
目的:自动发现server2并添加
<1> 先将上一步已经添加的server2主机删除,在配置中点击事件源:自动发现,然后选择动作 必须先启用动作才能创建自动发现规则
<2>点击自动发现,创建自动发现规则 名称:local network
ip范围:172.25.4.1-254
检查内的内容为zabbix客户端“system.uname”
然后点击已启用
然后在最上面点击监控 点击自动发现 会发现已经发现设备server2
(3)自动注册
目的:通过自动注册发现server3
开启server3,过程和手动发现监控主机中server2前面的过程一样
<1>在监控界面 监控中将存在的动作删除,在动作中选择自动注册
添加新的动作,名称:auto_reg(随意)
选择主机名称包含server3
在动作中还要添加操作(添加主机 添加主机群组linux servers 链接到模板template os linux),点击启用
<2> 然后在配置中主机中可以发现添加server3添加进来了