zabbix邮箱报警配置
第三方邮箱警告配置
安装postfix软件
[root@haha ~]# dnf -y install postfix
修改postfix的主配置文件,并重启服务和设置下次启动生效
[root@haha ~]# vim /etc/postfix/main.cf
在该行后面加上$mydomain
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain
[root@haha ~]# systemctl restart postfix.service
[root@haha ~]# systemctl enable postfix.service
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
安装mailx软件包
[root@haha ~]# dnf -y install mailx
注册网易邮箱
开启SMTP服务和POP3服务,会生成一个授权码,需要记住这个授权码

配置报警媒介类型






再次测试,客户端连接数超过7个,看163邮箱是否能收到邮件
[root@hehe ~]# who | wc -l
10
[root@hehe ~]#


当连接数少于7个的时候,修复好了,163邮箱会再次收到修复成功的邮件
[root@hehe ~]# who | wc -l
6
[root@hehe ~]#


第三方QQ邮箱+脚本告警配置
修改mailx配置文件
[root@haha ~]# vim /etc/mail.rc
set bsdcompat
set from=2301501656@qq.com
set smtp=smtp.qq.com
set smtp-auth-user=2301501656@qq.com
set smtp-auth-password=imcycxhtldvpeajj
set smtp-auth=login
set ssl-verify=ignore
[root@haha ~]# chown -R zabbix:zabbix /etc/mail.rc
在zabbix服务端写邮件发送脚本
[root@haha ~]# vim /usr/lib/zabbix/alertscripts/haha.sh
#!/bin/bash
messages=`echo $3 | tr '\r\n' '\n'`
subject=`echo $2 | tr '\r\n' '\n'`
echo "${messages}" | mailx -s "${subject}" $1
root@haha ~]# chmod +x /usr/lib/zabbix/alertscripts/haha.sh
[root@haha ~]# cd /usr/lib/zabbix/alertscripts/
[root@haha alertscripts]# ls
haha.sh
[root@haha alertscripts]# chown zabbix.zabbix haha.sh
[root@haha alertscripts]# ll /usr/lib/zabbix/alertscripts/
总用量 4
-rwxr-xr-x 1 zabbix zabbix 130 9月 4 23:25 haha.sh
[root@haha alertscripts]#
测试邮箱能否接收邮件
[root@haha] cd /usr/lib/zabbix/alertscripts/
[root@haha alertscripts]# ./haha.sh 2301501656@qq.com “zabbix test mail” “test
[root@haha alertscripts]#

创建报警媒介类型



创建动作



验证



本文详细介绍了如何在Zabbix中配置邮箱报警,包括安装postfix、设置mydestination、使用mailx发送邮件至163和QQ邮箱,并通过脚本实现第三方告警。重点展示了邮件报警媒介的设置和验证过程。
541

被折叠的 条评论
为什么被折叠?



