zoukankan      html  css  js  c++  java
  • 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为邮件内容

  • 相关阅读:
    单线制DS18B20温度传感器LED数码管显示当前的温度值
    AD转换器的主要指标
    关于swiper动态更改,无法更新的悖论
    在360的兼容模式下关于innerHTML=“”,引发的问题
    比较两个字符串的相似度
    WebSocket使用
    事件绑定addEventListener
    插件开发优缺点
    插件开发宗旨
    学会用博客
  • 原文地址:https://www.cnblogs.com/wuxie1989/p/5505766.html
Copyright © 2011-2022 走看看