jojo's blog--快乐忧伤都与你同在
为梦想而来,为自由而生。 性情若水,风起水兴,风息水止,故时而激荡,时又清平……
posts - 11,  comments - 30,  trackbacks - 0
nagios中文:http://nagios-cn.sourceforge.net/
nagiso官方网站:http://www.nagios.org/

Ununtu下Nagios信息发送方式:
1.mail
如果要接收Nagios的EMail警报,需要安装(Postfix)包

sudo apt-get install mailx

需要编辑Nagios里的EMail通知送出命令,它位于/usr/local/nagios/etc/commands.cfg文件中,将里面的'/bin/mail'全部替换为'/usr/bin/mail'。一旦设置好需要重启动Nagios以使配置生效。

sudo /etc/init.d/nagios restart

2.MSN
  用php来发送MSN信息。
  wget http://downloads.fanatic.net.nz/dev/php/sendMsg.zip
  unzip sendMsg.zip
  mv sendMsg /path/to/web/dir/msn
  可以先打开 http://server/msn/index.php 测试一下能否发送。如果没有问题,可以写一个脚本来执行 MSN 信息发送命令:
  /usr/local/nagios/libexec/msn_send.sh:
  #!/bin/sh
  wget -O - -q --post-data="sender=nagios@live.cn&password=password& 
  recipient=$1&message=$2" http://server/msn/index.php > /dev/null

  chmod +x /usr/local/nagios/libexec/msn_send.sh

/usr/local/nagios/etc/objects/commands.cfg:

define command{
        command_name    notify-host-by-msn
        command_line    /usr/local/nagios/libexec/msn_send.sh $CONTACTEMAIL$ "`/usr/bin/printf "%b" "***** Monitor *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"`"
        }

define command{
        command_name    notify-service-by-msn
        command_line    /usr/local/nagios/libexec/msn_send.sh $CONTACTEMAIL$ "`/usr/bin/printf "%b" "***** Monitor *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"`"
        }

/usr/local/nagios/etcobjects/contacts.cfg :

define contact{
        contact_name                    nagios
        alias                           Nagios Msn
        use                             generic-contact
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r
        host_notification_options       d,u,r
        service_notification_commands   notify-service-by-msn
        host_notification_commands      notify-host-by-msn
}

参考于:http://blog.bluedata.org/nagios-notification-type/
3.飞信通知

飞信官方网站:http://www.it-adv.net/
  下载:fetion20080910048-linux.tar.gz 和 library32.rar(版本不断更新)
  tar xvfz fetion_linux_20080402.tar.gz
  cd install
  sudo cp fetion /usr/bin
  fetion -h
如果出现如下错误:
  error while loading shared libraries: libACE.so.5.4.7: cannot open shared object file: No such file or directory
  说明缺少运行的库文件。
解决方法:
   a.sudo apt-get install libACE.so.5.4.7 libACE_SSL.so.5.4.7
     (可能你的ubuntu已经不提供安装这两个库文件,采用下面的方案)
   b.unrar e library32.rar
     cd library32
     sudo cp *.* /lib/
     sudo cp *.* /usr/lib/
  重新执行 fetion -h.应该能看到所要的结果。
  如果你有飞信号,可以执行一下。
  fetion  -u 飞信号 -p pwd 来登录。
/usr/local/nagios/etc/objects/commands.cfg:
# 'notify-service-by-fetion' command definition                                                                            
define command{
        command_name notify-service-by-fetion
        command_line /usr/bin/feiton -u 13888888888  -p 123456   -t $CONTACTPAGER$ -m "$HOSTNAME$ $SERVICEDESC$ is $SERVICESTATE$ on $TIME$ result is $SERVICEOUTPUT$" $CONTACTPAGER$
        }
/usr/local/nagios/etcobjects/contacts.cfg :
define contact{
contact_name                    fetion
alias                           nagios admin
host_notification_period        24x7
service_notification_period     24x7
host_notification_options       d,r,
service_notification_options    c,w,r
service_notification_commands   notify-service-by-email,notify-service-by-fetion
#       service_notification_commands   notify-service-by-email                                                            
host_notification_commands      notify-host-by-email
pager                           158010775111
}


最后将定义的contact添加到contactgroup中:
define contactgroup{
        contactgroup_name       admins
        alias                   Nagios Administrators
        members                 nagiosadmin,nagios,fetion
}
当你定义一个主机的时候:
/usr/local/nagios/etc/objects/templates:
# Linux host definition template - This is NOT a real host, just a template!                                               

define host{
        name                            linux-server    ; The name of this host template
        use                             generic-host    ; This template inherits other values from the generic-host template
check_period                    24x7            ; By default, Linux hosts are checked round the clock
check_interval                  5               ; Actively check the host every 5 minutes
retry_interval                  1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts              10              ; Check each Linux host 10 times (max)
        check_command                   check-host-alive ; Default command to check Linux hosts
        notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
                                                        ; Note that the notification_period variable is being overridden from
                                                        ; the value that is inherited from the generic-host template!
notification_interval           120             ; Resend notifications every 2 hours
        notification_options            d,u,r           ; Only send notifications for specific host states
contact_groups                  admins          ;使用的联系组为admins
        register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

  此处参考:http://yang2001.blog.51cto.com/25307/73164
posted on 2009-05-28 22:01 Blog of JoJo 阅读(362) 评论(0)  编辑  收藏 所属分类: 每日一记

只有注册用户登录后才能发表评论。


网站导航:
 

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(6)

随笔档案

文章分类

文章档案

新闻分类

新闻档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜