Zabbix三种邮箱告警配置
本次环境为:
| 环境 | IP地址 | 主机名 | 需要安装的应用 | 系统版本 |
|---|---|---|---|---|
| 服务端 | 192.168.122.143 | zabbix | lamp zabbix_server zabbix_agent | RedHat 8 |
| 客户端 | 192.168.122.148 | node1 | zabbix_agent | RedHat 8 |
zabbix配置本地邮箱告警
安装服务
[root@zabbix ~]# yum -y install mailx postfix
启动服务后检查25端口是否开启
[root@zabbix ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port 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 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 [::]:22 [::]:* LISTEN 0 100 [::1]:25 [::]:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 *:80 *:*
配置本地邮箱:
[root@zabbix ~]# vim /usr/local/etc/zabbix_server.conf ### Option: AlertScriptsPath # Full path to location of custom alert scripts. # Default depends on compilation options. # To see the default path run command "zabbix_server --help". # # Mandatory: no # Default: AlertScriptsPath=/usr/local/share/zabbix/alertscripts //取消注释并修改成绝对路径 #!/bin/bash [root@zabbix ~]# pkill zabbix [root@zabbix ~]# zabbix_server [root@zabbix ~]# zabbix_agentd [root@zabbix ~]# vim /usr/local/share/zabbix/alertscripts/sendmail.sh message=$(echo $2 | tr "\r\n" "\n") subject=$(echo $3 | tr "\r\n" "\n") mailto=$1 echo "$message" | mail -s "$subject" $mailto [root@zabbix ~]# chmod +x /usr/local/share/zabbix/alertscripts/sendmail.sh [root@zabbix ~]# su - zabbix -s /bin/bash [zabbix@zabbix root]$ /usr/local/share/zabbix/alertscripts/sendmail.sh 2541927049@qq.com "ello world" "123""

配置本地邮箱并配合脚本:





[root@node1 ~]# echo 'jjww' >> /tmp/abc //触发报警

第三方邮箱脚本告警配置




[root@zabbix ~]# echo "jjww" >> /tmp/1 [root@zabbix ~]# //测试

浙公网安备 33010602011771号