一、用邮件接收告警
1.安装mailx
[[email protected] ~]# yum install -y mailx
2.给自己发邮件
[[email protected] ~]# mail root
Subject: hello yan
EOT
Null message body; hope that's ok
如果没有发出去,这里会显示1
[[email protected] ~]# mailq
Mail queue is empty
3.查看邮件
[[email protected] ~]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root Sun May 12 14:30 18/599 "hello yan"
& 1
Message 1:
From [email protected] Sun May 12 14:30:06 2019
Return-Path: <[email protected]>
X-Original-To: root
Delivered-To: [email protected]
Date: Sun, 12 May 2019 14:30:06 +0800
To: [email protected]
Subject: hello yan
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: [email protected] (root)
Status: R
& R
To: [email protected]
Subject: Re: hello yan
4.添加火墙策略,是虚拟机可以上网
[[email protected] ~]# iptables -t nat -nL
[[email protected] ~]# iptables -t nat -I POSTROUTING -s 172.25.19.0/24 -j MASQUERADE
[r[email protected] ~]# sysctl -a | grep ip_forward
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_use_pmtu = 0
[[email protected] ~]# ping www.baidu.com
[[email protected] ~]# systemctl stop zabbix-agent
5.配置web中的zabbix
- 管理 —>消息媒介类型—> 勾选除了Email的其他项—> 禁用
- 管理—> 用户—> admin —>报警媒介—> 添加 —>填写信息—> 更新
测试:
关闭一个节点,zabbix会给QQ邮箱发送告警邮件
二、.部署onealert云告警
1.注册云告警账号
访问www.onitem.com,注册一个账号,设置个人信息
2.安装告警软件(必须在/usr/lib/zabbix/alertscripts/目录下,否则会报错,告警不能及时送达)
应用 Key: a6c6bbab-79b5-bab6-3978-c277cae048a3
[[email protected] ~]# tar zxf oneitsm_zabbix_release-1.2.0.tar.gz -C /usr/lib/zabbix/alertscripts/
[[email protected] ~]# cd /usr/lib/zabbix/alertscripts/
[[email protected] alertscripts]# ls
oneitsm
[[email protected] alertscripts]# cd oneitsm/
[[email protected] oneitsm]# ls
bin logs release update
[[email protected] oneitsm]# cd bin/
[[email protected] bin]# ls
alert.sh install.sh log.sh update.sh
[[email protected] bin]# ./install.sh a6c6bbab-79b5-bab6-3978-c277cae048a3
start to create config file...
Zabbix管理地址: http://172.25.19.1/zabbix
Zabbix管理员账号: Admin
Zabbix管理员密码:
- 安装时后面要加应用key
3.在zabbix中添加告警媒介
- 配置通知策略
4.测试:关闭server2的agent
[[email protected] ~]# systemctl stop zabbix-agent
- 5分钟左右后,qq邮箱收到邮件
- 再手动开启server2的agent