######1、实验环境
- server10 172.25.29.10 rhel7.3 zabbix-server
- server6 172.25.29.6 rhel6.5 zabbix-agent
- server11 172.25.29.11 rhel7.3 zabbix-proxy
######2、onealert告警
(1)首先我们需保证zabbix-server主机是可以连网的
#########主机:
[root@foundation29 images]# ping www.baidu.com
PING www.baidu.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=52 time=63.1 ms
[root@foundation29 images]# iptables -t nat -I POSTROUTING -s 172.25.29.0/24 -j MASQUERADE
#########server10:
[root@server10 zabbix]# route add default gw 172.25.29.250
[root@server10 zabbix]# route -n
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.25.29.250 0.0.0.0 UG 0 0 0 eth0
[root@server10 zabbix]# vim /etc/resolv.conf
nameserver 114.114.114.114
[root@server10 zabbix]# ping www.baidu.com
PING www.baidu.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=51 time=51.6 ms
(2)onealert添加zabbix应及通知策略
获得了应用key,添加通知策略,可自定义通知时间、方式等
#########server10:
[root@server10 3.4]# cd /etc/zabbix/
[root@server10 zabbix]# vim zabbix_server.conf
490 AlertScriptsPath=/usr/lib/zabbix/alertscripts
[root@server10 zabbix]# cd /usr/lib/zabbix/alertscripts //警告脚本路径,解压文件需放入该路径
[root@server10 alertscripts]# tar zxf oneitsm_zabbix_release-1.2.0.tar.gz
[root@server10 oneitsm]# cd oneitsm
[root@server10 oneitsm]# cd bin/
[root@server10 bin]# ./install.sh d043e5d0-3a52-b032-9ad8-753491ecf0e4
start to create config file… //应用key
Zabbix管理地址: http://172.25.29.10/zabbix
Zabbix管理员账号: Admin
Zabbix管理员密码: //这里是WESTOS.com777
(3)停用相关触发器及用户,以防产生干扰
(4)给admin添加报警媒介
#########测试:
[root@server6 ~]# /etc/init.d/zabbix-agent stop //停agent
(1)查看问题:
(2)onealert:待处理问题
[root@server6 ~]# /etc/init.d/zabbix-agent start //开启agent
(3)onealert:问题处理完成
######3、agent被动变主动
#########server11:
[root@server11 ~]# yum install zabbix-agent-3.4.6-1.el7.x86_64.rpm
[root@server11 ~]# cd /etc/zabbix/
[root@server11 zabbix]# vim zabbix_agentd.conf
97 #Server=127.0.0.1
122 StartAgents=0
138 ServerActive=172.25.29.10
149 Hostname=server11
[root@server11 zabbix]# systemctl start zabbix-agent
[root@server11 zabbix]# netstat -antlp
(1)点击OS Linux ,全克隆,生成OS Linux.active
(2)点击监控项,应用
(3)批量更新
(4)监控项,主动型
#########server11:
[root@server11 zabbix]# vim zabbix_agentd.conf
97 Server=172.25.29.10
122 #StartAgents=0
138 ServerActive=172.25.29.10
149 Hostname=server11
[root@server11 zabbix]# systemctl restart zabbix-agent
添加OS Linux active模版
######4、zabbix-proxy
[root@server11 ~]# yum install zabbix-proxy-mysql-3.4.6-1.el7.x86_64.rpm fping-3.10-1.el7.x86_64.rpm
[root@server11 ~]# cd /etc/zabbix
[root@server11 zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d zabbix_proxy.conf
[root@server11 zabbix]# vim zabbix_proxy.conf
24 Server=172.25.29.10
190 DBPassword=WESTOS.com777
197 DBSocket=/var/lib/mysql/mysql.sock
[root@server11 zabbix]# yum install mariadb-server
[root@server11 zabbix]# mysql
MariaDB [(none)]> create database zabbix_proxy character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'WESTOS.com777';
[root@server11 zabbix]# cd /usr/share/doc/
[root@server11 doc]# cd zabbix-proxy-mysql-3.4.6/
[root@server11 zabbix-proxy-mysql-3.4.6]# zcat schema.sql.gz |mysql -u zabbix -p zabbix_proxy
Enter password:
[root@server11 zabbix-proxy-mysql-3.4.6]# systemctl start zabbix-proxy
添加代理程序
[root@server6 zabbix]# vim zabbix_agentd.conf
97 Server=172.25.29.11 //修改为proxy
138 ServerActive=172.25.29.11
[root@server6 zabbix]# /etc/init.d/zabbix-agent restart