zoukankan      html  css  js  c++  java
  • Zabbix三种邮箱告警配置

    Zabbix三种邮箱告警配置


    本次环境为:

    环境 IP地址 主机名 需要安装的应用 系统版本
    服务端 192.168.100.1 zabbix lamp zabbix_server zabbix_agent RedHat 8
    客户端 192.168.100.2 node1 zabbix_agent RedHat 8

    环境配置步骤请见:Zabbix部署Zabbix配置


    本地邮箱告警配置

    //安装mailx和postfix
    [root@zabbix ~]# yum -y install mailx 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         100                127.0.0.1:25                 0.0.0.0:*    
    LISTEN    0         100                    [::1]:25                    [::]:*
    
    //修改域名
    [root@zabbix ~]# hostnamectl set-hostname zabbix.example.com
    [root@zabbix ~]# bash
    [root@zabbix ~]# hostname
    zabbix.example.com
    
    //给qq邮箱发送主题为Test内容为abc的邮件
    [root@zabbix ~]# echo 'abc' | mail -s "Test" 1312230872@qq.com
    

    验证

    1


    本地邮箱+脚本告警配置

    本地邮箱告警脚本目录默认是/usr/local/share/zabbix/alertscripts

    //设置告警脚本目录
    [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     //取消注释并修改成绝对路径
    
    //重启zabbix
    [root@zabbix ~]# pkill zabbix
    [root@zabbix ~]# zabbix_server 
    [root@zabbix ~]# zabbix_agentd
    
    //编写脚本
    [root@zabbix ~]# cd /usr/local/share/zabbix/alertscripts/
    [root@zabbix alertscripts]# vim sendmail.sh
    #/bin/bash
    
    MESSAGE=$(echo $2 | tr "
    " "
    ")
    SUBJECT=$(echo $3 | tr "
    " "
    ")
    MAILTO=$1
    
    echo "$MESSAGE" | mail -s "$SUBJECT" $MAILTO
    
    //赋予脚本执行权限
    [root@zabbix alertscripts]# chmod +x sendmail.sh
    
    //测试
    [root@zabbix ~]# su - zabbix -s /bin/bash
    su: warning: cannot change directory to /home/zabbix: No such file or directory
    [zabbix@zabbix root]$ /usr/local/share/zabbix/alertscripts/sendmail.sh 1312230872@qq.com "abc2" "Test2"
    

    验证

    2

    本地邮箱脚本告警配置

    添加媒介

    Administration --- Media types

    3

    添加媒介信息

    6


    设置收件人

    Administration --- Users --- Admin

    4


    设置动作

    Configuration --- Actions

    5


    触发触发器

    [root@node1 ~]# echo 'abc' >> /tmp/baozi
    

    验证

    7


    第三方邮箱网页告警+脚本告警配置

    第三方邮箱网页告警

    配置步骤请见:Zabbix配置


    第三方邮箱网页告警脚本告警配置

    配置mail.rc

    SMTP的主要配置如下:

    set smtp=smtps://smtp.xxx.com:465   # 这里填入smtp地址
    set smtp-auth=login                 # 认证方式
    set smtp-auth-user=user@xxx.com     # 这里输入邮箱账号
    set smtp-auth-password=password     # 这里填入密码
    set ssl-verify=ignore               # 忽略证书警告
    set nss-config-dir=/etc/pki/nssdb   # 证书所在目录
    set from=user@xxx.com               # 设置发信人邮箱和昵称
    #set smtp-use-starttls=yes          # STARTTLS时使用
    

    文件默认在/etc/mail.rc

    //配置mail.rc
    [root@zabbix ~]# vim /etc/mail.rc
    #在最后一行添加如下信息
    set smtp=smtp.163.com
    set smtp-auth=login
    set smtp-auth-user=qinghao_yu@163.com
    set smtp-auth-password=XXXXXXXXXXXXX		#这里为授权码
    set from=qinghao_yu@163.com
    

    第三方邮箱脚本告警配置

    添加媒介

    Administration --- Media types

    3

    添加媒介信息

    6


    设置收件人

    Administration --- Users --- Admin

    4


    设置动作

    Configuration --- Actions

    5


    触发触发器

    [root@node1 ~]# echo 'abc' >> /tmp/baozi
    

    验证

    8

  • 相关阅读:
    势函数的构造
    10.29模拟赛总结
    10.29vp总结
    10.25模拟赛总结
    10.24模拟赛总结
    线段树练习
    一键挖矿
    P1972 [SDOI2009]HH的项链
    P3901 数列找不同
    P5546 [POI2000]公共串
  • 原文地址:https://www.cnblogs.com/yuqinghao/p/14705680.html
Copyright © 2011-2022 走看看