//安装postfix
[root@zabbix ~]# yum -y install postfix
//开机自动启动postfix
[root@zabbix ~]# systemctl enable --now postfix
[root@zabbix ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128 0.0.0.0:10051 0.0.0.0:*
LISTEN 0 128 0.0.0.0:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
[root@zabbix ~]#
[root@zabbix ~]# yum -y install mailx
配置本地邮箱告警
浏览器登录zabbix后台,Administration -> Media types -> Email:
定义用户媒介
在配置管理界面设置用户的收件箱配置媒介
更新updata
配置告警方式和动作
第三方邮件网页配置警告告警
在管理界面配置用户添加收件人的信息
在管理界面定义媒介类型
配置动作action
该组发还是用户发
发的时候要选择发的方式
触发告警并验证
写脚本
[root@zabbix ~]# cd /usr/local/share/zabbix/
[root@zabbix zabbix]# ls
alertscripts externalscripts
[root@zabbix alertscripts]# pwd
/usr/local/share/zabbix/alertscripts
[root@zabbix zabbix]# chown -R zabbix.zabbix alertscripts/
[root@zabbix zabbix]# ll
total 0
drwxr-xr-x 2 zabbix zabbix 45 Nov 7 01:06 alertscripts
drwxr-xr-x 2 zabbix zabbix 6 Nov 3 23:49 externalscripts
[root@zabbix zabbix]#
[root@zabbix ~]# cd /usr/local/etc/
[root@zabbix etc]# vim zabbix_server.conf
[root@zabbix etc]# chown -R zabbix.zabbix /usr/local/share/zabbix/
[root@zabbix alertscripts]# vim sendmail.sh
#!/bin/bash
message=$(echo $1|tr '\r\n' '\n')
subject=$(echo $2|tr '\r\n' '\n')
echo "$message" | /usr/bin/mail -s "$subject" $3
[root@zabbix alertscripts]# chmod +x sendmail.sh
[root@150 ~]# echo 'hell123' >> /etc/abc
[root@150 ~]# echo 'hell123' >> /etc/abc