首页 > 其他 > 详细

zabbix邮箱告警的三种方式

时间:2021-05-22 10:44:40      阅读:15      评论:0      收藏:0      [点我收藏+]

1.环境说明:

环境 ip hostname 要安装的应用
服务器 192.168.59.131 server lamp架构
zabbix server
zabbix agent
客户端 192.168.59.133 139 zabbix agent
   
 
 
 
 
 
 

2.zabbix配置本地邮箱告警

安装服务

[root@server ~]# dnf -y install postfix mailx

启动

[root@server etc]# systemctl enable --now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
[root@server etc]# 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              80                                 *:3306                             *:*           
LISTEN        0              128                                *:80                               *:*           
LISTEN        0              128                             [::]:22                            [::]:*           
LISTEN        0              100                            [::1]:25                            [::]:*           

手动发送邮件

[root@server etc]# echo "biedengle"|mail -s test 790650910@qq.com

技术分享图片

 

 配置

[root@server etc]#  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

[root@server etc]# vim /usr/local/share/zabbix/alertscripts/sendmail.sh
#!/bin/bash
  
msg=$(echo $1 | tr "\r\n" "\n" )
sub=$(echo $2 | tr "\r\n" "\n" )
 email=$3 echo $msg |mail -s $sub $email
[root@server etc]# /usr/local/share/zabbix/alertscripts/sendmail.sh biedengle zwy 790650910@qq.com

技术分享图片

配置本地邮箱脚本

技术分享图片

技术分享图片

 

 

 

 技术分享图片

 

 技术分享图片

 

 

 

 技术分享图片

 

 技术分享图片

 

 用第三方邮箱配置本地脚本

[root@server ~]# vim /etc/mail.rc 
set SMTP=smtp.163.com
set SMTP-AUTH=login
set SMTP-AUTH-USER=x790650910@163.com
set SMTP-AUTH-PASSWORD=TYRKRTKZYGCHLWRA
set FROM=x790650910@163.com

[root@server ~]# echo ‘jjyy‘|mail -s ‘hehe‘ 790650910@qq.com

 

 

 

 

zabbix邮箱告警的三种方式

原文:https://www.cnblogs.com/Mariko/p/14798013.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!