• nagios配置邮件报警


    1、配置sendmail

      vi /etc/mail.rc

      加入以下行

      set bsdcompat

      set from=邮件用户名@domain.com smtp=smtp.126.com set smtp-auth-user=邮件用户名 smtp-auth-password=邮箱密码 set smtp-auth=login

    2、检查commands.cfg

      

    ################################################################################
    #
    # SAMPLE NOTIFICATION COMMANDS
    #
    # These are some example notification commands.  They may or may not work on
    # your system without modification.  As an example, some systems will require 
    # you to use "/usr/bin/mailx" instead of "/usr/bin/mail" in the commands below.
    #
    ################################################################################
    
    
    # 'notify-host-by-email' command definition
    define command{
            command_name    notify-host-by-email
            command_line    /usr/bin/printf "%b" "***** Nagios *****
    
    Notification Type: $NOTIFICATIONTYPE$
    Host: $HOSTNAME$
    State: $HOSTSTATE$
    Address: $HOSTADDRESS$
    Info: $HOSTOUTPUT$
    
    Date/Time: $LONGDATETIME$
    " | /bin/mail -s "
    ** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
            }
    
    # 'notify-service-by-email' command definition
    define command{
            command_name    notify-service-by-email
            command_line    /usr/bin/printf "%b" "***** Nagios *****
    
    Notification Type: $NOTIFICATIONTYPE$
    
    Service: $SERVICEDESC$
    Host: $HOSTALIAS$
    Address: $HOSTADDRESS$
    State: $SERVICESTATE$
    
    Date/Time: $LONGDATETIME$
    
    Additi
    onal Info:
    
    $SERVICEOUTPUT$
    " | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
            }

    这是正确的命令配置,其中最重要的就是/bin/mail后边的命令配置

    3、mqueue

    ls /var/spool/mqueue

    这个目录存储的是邮件发送队列,

    如果这个里边满了不但会影响程序的运行,而且sendmail容易死掉,所以必要的时候要删除。
    4、修改联系人地址
    vi /usr/local/nagios/etc/objects/contacts.cfg
    修改nagios@localhost为联系人的地址
    5、检查所传送的电子邮件是否送出,或滞留在邮件服务器中
    /usr/lib/sendmail -bp

    若屏幕显示为“Mail queue is empty” 的信息,表示mail 已送出。

    6、发送测试邮件

      mail -s "test" luoyelin1989@126.com <content.txt

      content.txt为邮件内容

  • 相关阅读:
    POJ3984 输出路径
    ACWING 844.走迷宫
    N皇后问题 DFS解法(给出两种)
    Codeforces Round #632 (Div. 2)
    HDU--1198 Farm Irrigation (并查集做法+DFS做法)
    HDU--1325 并查集判树(有向无环图)
    python接口自动化(二十) 发xml格式post请求
    python接口自动化(十九) 签名(signature)鉴权(authentication)之加密(HEX,MD5,HMAC-SHA256)
    python接口自动化(十八) 下载excel文件(Content-Type:octets/stream)
    python接口自动化(十七) requests获取响应时间(elapsed)与超时(timeout)
  • 原文地址:https://www.cnblogs.com/wuxie1989/p/5505766.html
Copyright © 2020-2023  润新知