zabbix添加监控主机
环境
IP | 服务 |
---|---|
192.168.40.10 | zabbix-server |
192.168.40.11 | zabbix-agent |
192.168.40.12 | zabbix-agent |
被监控端:zabbix-agent:192.168.40
1.添加监控主机
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
#如果需要被监控的机器是zabbix-server本机那么就直接安装zabbix-anent
[root@localhost ~]#yum -y install zabbix-agent
#修改zabbix-agent
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
cat /etc/zabbix/zabbix_agentd.conf | grep Server
Server=127.0.0.1 #写上zabbix-server端地址
#在配置文件写上zabbix-server端的地址后,重启zabbix-server和zabbix-agent
[root@localhost ~]# systemctl restart zabbix-server.service
[root@localhost ~]# systemctl restart zabbix-agent.service
1.2.页面添加监控主机
1.2.1.点击创建主机
1.3.监控主机配置
1.4.添加监控主机模板
1.5.查看监控状态
1.5.2.添加完成后,不会更新主机比较慢,重启后,会显示为灰色,可以重启zabbix-server和zabbix-agent,来快速生效。
[root@localhost ~]# systemctl restart zabbix-server.service
[root@localhost ~]# systemctl restart zabbix-agent.service
1.6.自定义监控项
注意:默认添加主机后,会自带一些监控项,但是非常有限,如果想达到理想的效果,那么我们就需要自己定义监控项内容。
#获取硬盘每秒读写使用率
[root@localhost ~]# iostat
Linux 3.10.0-1127.el7.x86_64 (localhost.localdomain) 2021年04月25日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.32 0.02 0.30 0.01 0.00 99.34
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 2.34 7.19 53.34 1193360 8858866
scd0 0.00 0.01 0.00 1050 0
dm-0 2.36 6.96 53.29 1156579 8850026
dm-1 0.01 0.03 0.03 5096 4664
dm-2 0.00 0.01 0.01 1412 2048
[root@localhost ~]# iostat |grep sda | awk '{print $2}'
2.34
#监控项格式
#UserParameter=监控项名称,命令。
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf
UserParameter=sda_iostat,iostat |grep sda | awk '{print $2}' #自定义监控项
#添加完成之后重启zabbix-agent
[root@localhost ~]# systemctl restart zabbix-agent.service
1.7.在页面点击监控项
1.8.点击创建监控项
1.9.监控项内容
1.3.监控项数值增加
1.4.重启zabbix-serve
#添加完成之后重启zabbix-agent
[root@localhost ~]# systemctl restart zabbix-server.service