1.本机默认邮箱发送警告
- 客户端上的操作
//修改客户端的主机名
[root@destop ~]# hostnamectl set-hostname zabbix.server.com
[root@destop ~]# bash
//修改/etc/hosts文件
[root@zabbix ~]# vim /etc/hosts
127.0.0.1 zabbix.service.com
//安装mailx
[root@zabbix ~]# yum -y install mailx
- 修改邮箱的白名单
- 邮件收发测试
//测试本地发送邮件
[root@zabbix ~]# echo '123' | mail -s 'text' yizhen_w@qq.com
- 配置告警媒介(在此前已经配置好主机组、主机、监视器和触发器)
- 在用户配置中设置使用的告警媒介
- 手动触发告警,测试
[root@zabbix ~]# userdel -r wyz
使用第三方邮箱发送邮件告警(126邮箱)
- 客户端配置(已安装mailx)
[root@zabbix ~]# vim /etc/mail.rc
set from=******** //你的邮箱地址
set smtp=smtp.126.com
set smtp-auth-user=****** //你的邮箱地址
set smtp-auth-password=*******//邮箱密码
set smtp-auth=login
- 在服务端上写发送告警信息脚本
//写脚本
[root@zabbix share]# vim /usr/local/share/zabbix/alertscripts/sendmail.sh
#!/bin/bash
subject=$(echo $2 |tr "\r\n" "\n")
message=$(echo $3 |tr "\r\n" "\n")
echo "$message" | /usr/bin/mail -s "$subject" $1 &>/tmp/sendmail.log
[root@server ~]# cd /usr/local/share/zabbix/
[root@server zabbix]# chown -R zabbix.zabbix alertscripts
[root@server zabbix]# chmod +x alertscripts/sendmail.sh
[root@server ~]# pkill zabbix
[root@server ~]# zabbix_server
[root@server ~]# zabbix_agentd
[root@server ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 80 :::3306 :::*
[root@server alertscripts]# bash sendmail.sh yizhen_w@qq.com test hello world
- 配置媒介
- 配置用户
- 配置动作
- 触发告警,测试
在web界面配置邮箱
- 添加/配置媒介
- 配置用户
-触发告警测试