登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

herb

喜欢写博,喜欢安静,喜欢挑战!

 
 
 

日志

 
 

nagios设置邮件告警  

2011-06-29 23:27:35|  分类: Monit |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

    搭建nagios的目的就是为了他的报警系统,nagios据我所了解可以有三种报警:
  一、声音报警
  二、电子邮件报警
  三、手机短讯报警
      四、传真告警
  下面是我的邮件报警的配置过程:
  1、开启系统自带的sendmail邮件系统
  service sendmail start
  如果没有安装,可以yum一下
  yum install -y sendmail*
  service sendmail restart
  测试发送邮件:
  echo "test" | mail 88fly@163.com
  注:iptables和selinux设置
  2、配置nagios中报警邮箱
  vi /usr/local/nagios/etc/objects/contacts.cfg
         define contact{
         contact_name                    mail                    ; Short name of user
         alias                           null             ; Full name of user
        service_notification_period     24x7 (和如下时间模版(timeperiod)保持一致)
         host_notification_period        24x7
         service_notification_options    w,u,c,r
         host_notification_options       d,u,r
         service_notification_commands   notify-service-by-email
         host_notification_commands      notify-host-by-email
         email                           88fly@163.com
         }
  在email那里加上自己的邮箱,如果有多个可以用逗号隔开
  3、设置报警方式:
define timeperiod{
        timeperiod_name 24x7
        alias           24 Hours A Day, 7 Days A Week
        sunday          00:00-24:00
        monday          00:00-24:00
        tuesday         00:00-24:00
        wednesday       00:00-24:00
        thursday        00:00-24:00
        friday          00:00-24:00
        saturday        00:00-24:00
        }
  这两个notify-service-by-email 和  notify-host-by-email    是在command.cfg那里定义的,看看是怎么定义的:# 'notify-service-by-email' command definition
define command{
        command_name    notify-service-by-email
        command_line      echo " ** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$HOSTADDRESS$ $SERVICEDESC$ is $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$ Additional Info:$SERVICEOUTPUT$ "| formail -I "Subject: $HOSTADDRESS$*$SERVICEOUTPUT$*$LONGDATETIME$"| sendmail -oi $CONTACTEMAIL$
        }

# '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$
        }
  这里已经默认配置好,我们不用修改直接调用就是了
  最后重启服务:
  service nagios retart 
      进行破环性测试!


 

  评论这张
 
阅读(5310)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018