zabbix三种邮箱告警配置
实验环境:
ip地址 | 安装 | 主机名 | |
服务端 | 192.168.170.156 | lamp zabbix_server zabbix_agent | noide1 |
客户端 | 192.168.170.157 | zabbix_agent | node2 |
本地邮箱警告配置
[root@node1 ~]# yum -y install mailx [root@node1 ~]# yum -y install postfix [root@node1 ~]# systemctl enable --now postfix [root@node1 ~]# hostname node1.example.com [root@node1 ~]# echo "hehe" | mail -s "123" 1723827996@qq.com
本地邮箱加脚本警告配置
[root@node1 ~]# yum -y install mailx [root@node1 ~]# yum -y install postfix [root@node1 ~]# systemctl enable --now postfix [root@node1 ~]# hostname node1.example.com [root@node1 ~]# vim /usr/local/etc/zabbix_server.conf AlertScriptsPath=/usr/local/etc/alertscripts //取消注释,改为绝对路径 [root@node1 ~]# vim /usr/local/etc/alertscripts/sendmail.sh #!/bin/bash MESSAGE=$(echo $2 | tr "\r\n" "\n") SUBJECT=$(echo $3 | tr "\r\n" "\n") MAILTO=$1 echo "$MESSAGE" | mail -s "$SUBJECT" $MAILTO [root@node1 ~]# su - zabbix -s /bin/bash //用系统账户zabbix发送邮件 [zabbix@node1 etc]$ /usr/local/etc/alertscripts/sendmail.sh 1723827996@qq.com "haha" "nimei"
//触发触发器 [root@node2 ~]# echo 123 >> /tmp/hehe
第三方邮箱网页
触发触发器
[root@node2 ~]# echo 189 >> /tmp/hehe
验证
第三方邮箱网页告警脚本告警配置
配置mail.rc
//在服务端配置 [root@node1 ~]# vim /etc/mail.rc set smtp=smtps.163.com set smtp-auth=login set smtp-auth-user=你的发件人邮箱 set smtp-auth-password=第三方授权码 set from=你的发件人邮箱 [root@node1 ~]# cat /usr/local/etc/alertscripts/sendmail.sh #!/bin/bash MESSAGE=$(echo $2 | tr "\r\n" "\n") SUBJECT=$(echo $3 | tr "\r\n" "\n") MAILTO=$1 echo "$MESSAGE" | mail -s "$SUBJECT" $MAILTO
配置媒介
设置动作
第三方邮箱警告
添加媒介
配置动作