nagios邮件报警

nagios邮件报警设置:

当监控的设备出现异常的时候,报警是很有必要的。下面介绍下nagios的邮件报警机制。

cd  /etc/nagios/objects

vim  contact.cfg

define contact{

        contact_name                    nagiosadmin             ; Short name of user

        use                           generic-contact         ; Inherit default values fromgeneric-contact template (defined above)

        alias                           Nagios Admin            ; Full name of user

 

        email                          nagiosadmin@localhost   ;<<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

这是nagios默认的机制,提前编写好的报警机制应用了 generic-contact模板,在email处填写好接受报警邮件的地址。contact_name为收件人是谁。

vim templates.cfg

define contact{

name    generic-contact              

service_notification_period       24x7                

host_notification_period         24x7                          

service_notification_options      w,u,c,r,f,s           

host_notification_               options d,u,r,f,s                    

service_notification_commands    notify-service-by-email       

host_notification_commands      notify-host-by-email  

register                        0                    

        }

上面是nagios定义好的模板,其中包括报警的时间,什么情况下报警,以及报警使用的命令都有介绍。

vim command.cfg

#'notify-host-by-email' command definition

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$

        }

 

#'notify-service-by-email' command definition

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\nAdditionalInfo:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"$CONTACTEMAIL$

        }

上面是nagios定义好的报警信息应该怎么发送。我们可以在上面的情况下进行简单的修改即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值