分享

nagios发送邮件配置

 sslit 2012-08-20

nagios邮件监控可以配置sendmail,这里还是用mail命令完成。首先是编辑nagios.cfg,以前已经设置了,这里看看就行了

[root@localhost objects]# vi contacts.cfg  

define contact{  

contact_name user1  

alias Nagios Admin  

service_notification_period 24x7  

host_notification_period 24x7  

service_notification_options w,u,c,r  

host_notification_options d,r  

service_notification_commands notify-by-email  

host_notification_commands host-notify-by-email  

email xxxx@163.com  

pager 13800138000  

}  

 

define contactgroup{  

contactgroup_name admins  

alias Nagios Administrators  

members user1  

}  

notify-by-email和host-notify-by-email在command.cfg中定义了

#################

以下这个是在服务中单独设置

define service{  

use generic-service ; Name of service template to use  

host_name test_nrpe   

service_description apache  

is_volatile 0 #类似声音警告功能关闭  

check_period 24x7 #监控期限为24X7  

max_check_attempts 1 #最大重试次数  

normal_check_interval 1 #标准检测时间间隔 1分钟  

retry_check_interval 1 #重试时间间隔  

contact_groups admins #联系组  

notification_options w,u,c,r # w,u,c,r 发生这四种情况时,进行通告。  

notification_interval 960 # 通告间隔  

notification_period 24x7 #通告过期时间  

check_command check_http!100.0,20%!500.0,60%  

}  

 

在commands.cfg中用发送邮件命令用默认配置即可

define command{

        command_name    notify-host-by-email

        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

}

define command{

        command_name    notify-service-by-email

        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

}

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多