jojo's blog--快樂憂傷都與你同在
          為夢想而來,為自由而生。 性情若水,風起水興,風息水止,故時而激蕩,時又清平……
          posts - 11,  comments - 30,  trackbacks - 0
          nagios中文:http://nagios-cn.sourceforge.net/
          nagiso官方網(wǎng)站:http://www.nagios.org/

          Ununtu下Nagios信息發(fā)送方式:
          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來發(fā)送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 測試一下能否發(fā)送。如果沒有問題,可以寫一個腳本來執(zhí)行 MSN 信息發(fā)送命令:
            /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.飛信通知

          飛信官方網(wǎng)站: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
          如果出現(xiàn)如下錯誤:
            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已經(jīng)不提供安裝這兩個庫文件,采用下面的方案)
             b.unrar e library32.rar
               cd library32
               sudo cp *.* /lib/
               sudo cp *.* /usr/lib/
            重新執(zhí)行 fetion -h.應該能看到所要的結果。
            如果你有飛信號,可以執(zhí)行一下。
            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          ;使用的聯(lián)系組為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 閱讀(377) 評論(0)  編輯  收藏 所屬分類: 每日一記

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(6)

          隨筆檔案

          文章分類

          文章檔案

          新聞分類

          新聞檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 凤台县| 乌恰县| 历史| 缙云县| 江华| 儋州市| 新闻| 咸丰县| 琼结县| 六安市| 鸡泽县| 建阳市| 商水县| 汕头市| 琼结县| 安康市| 乌兰县| 阿瓦提县| 宜城市| 沾化县| 新巴尔虎右旗| 大厂| 四子王旗| 安乡县| 双鸭山市| 昌平区| 白朗县| 阳江市| 当涂县| 唐海县| 德阳市| 大连市| 南宁市| 嘉义市| 广州市| 贵南县| 浙江省| 陆河县| 拉孜县| 阜平县| 禹城市|