Nagios 設定E-mail 警示

Nagios 主機設定好個主機監控的項目後,可以設定當服務有異狀

發送e-mail 通知管理員

設定方式:

Nagios 發送郵件的方式為利用本機上的mail 指令

所以在Nagios主機上面我有安裝postfix套件 (個人習慣),然後將通知信relay 至Exchange主機

postifx 設定方式 :

修改 /etc/postfix/main.cf

relayhost = [x.x.x.x]

x.x.x.x exchange IP

Nagios 設定

修改

/etc/nagios/objects/contacts.cfg

設定說明:

define contact 區段設定每個管理員e-mail 及需要通知的類型

define contact 可以設定多個管理員 (如下列範例)

define contactgroup 設定通知群組 及成員

———————————————————————–

define contact{
        contact_name           roy       
         alias                           Roy Lee           
        service_notification_period     24×7
        host_notification_period        24×7
        service_notification_options    c,r
        host_notification_options       d,u,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           Roy.Lee@abc.com       

  }

define contact{
        contact_name           andy       
         alias                           Andy Liu           
        service_notification_period     24×7
        host_notification_period        24×7
        service_notification_options    c,r
        host_notification_options       d,u,r
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        email                           Andy.Liu@abc.com       

  }

 

define contactgroup{
        contactgroup_name       admins
        alias                   Administrators
        members                 roy,andy
}

—————————————————————————

再來就是設定監控主機的設定檔

notifications_enables 1  (0為不發通知信)

contact_groups  admins   (admins 群組會收到此通知信)

————————————————————————-

define host{
        host_name               web1
        alias                   Radius
        max_check_attempts      3
        notifications_enabled   1
        contact_groups          admins
        check_command           check-host-alive
        address                 10.65.32.7
        }
define service{
        use                             local-service         ; Name of service template to use
        host_name                web1
        max_check_attempts              3
        notifications_enabled           1
        contact_groups                  admins
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }

——————————————————————————–

測試 收到通知信

nagiosns



本篇瀏覽人數: 7218
分類: Nagios篇。這篇內容的永久連結

在〈Nagios 設定E-mail 警示〉中有 4 則留言

  1. KimChen表示:

    hi,我看了你這一個文章,去試了一下我的nagios,但會出現一些錯誤。你可以告訴我要如何解決嗎?我找了好多文章,但都沒辦法解決。

    Ubuntu 10.04
    Nagios 3.4.1
    sendmail

    當我使用下面這個指令測試後,會出現:Alert:… List:; syntax illegal for recipient addresses

    /usr/sbin/sendmail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$

發佈回覆給「榮哥」的留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *