zabbix4.0 邮件告警
作者:互联网
1. 安装sendmail
yum -y install sendmail
systemctl start sendmail.service #启动sendmail
systemctl enable sendmail.service #设置开机自起
systemctl stop sendmail.service #停止sendmail
2.安装邮件发送工具mailx: yum -y install mailx
4.配置外部邮箱:编辑 vi /etc/mail.rc
set from=q865158909@163.com
set smtp=smtp.163.com
set smtp-auth-user=q865158909@163.com
set smtp-auth-password=wb09199692
set smtp-auth=login
5. 测试邮箱发送(查看邮箱是否收到邮件):echo "zabbix test mail" |mail -s "zabbix" q865158909@163.com
6. 编写邮件发送脚本
1.vim /etc/zabbix/zabbix_server.conf
AlertScriptsPath=/etc/zabbix/alertscripts
2. 写邮件发送脚本
mkdir /etc/zabbix/alertscripts
cat mail.sh
#! /bin/bash
export LANG=en_US.UTF-8
to=$1
subject=$2
echo "$3" > /tmp/zabbix_mailbody
dos2unix /tmp/zabbix_mailbody
mail -s "$subject" "$to" < /tmp/zabbix_mailbody
rm -f /tmp/zabbix_mailbody
标签:tmp,sendmail,smtp,etc,zabbix,mail,告警,zabbix4.0,邮件 来源: https://www.cnblogs.com/Robi-9662/p/12340508.html