Shunze 學園 >電腦資訊學系 >OpenNMS > 《二》設定notification郵件通知 哈囉,還沒有註冊或者登入。請你[註冊|登入]
« 上一篇主題 下一篇主題 » 顯示成列印模式 | 增加到我的最愛
發表新主題 發表回覆
作者
主題
shunze
工友伯伯


註冊日期: 2002 04
來自: 潮汐終止之地
文章: 2370

shunze 線上
《分享》設定notification郵件通知引用回覆 編輯/刪除文章 搜尋由  發表的其他文章 回報給版主 IP 位置 回此頁最上方

我想做為網管軟體除了提供受控物件的狀態外,
最重要的還是在受控物件發生異常時,能做到主動的即時通知,
畢竟沒有人那麼閒,整天待在電腦前盯著螢幕看。

在OpenNMS上要做到郵件通知,可分為寄信機制定義通告事件收信人三個部分來討論。

  • 寄信機制
    OpenNMS的寄信機制支援了 透過mail server來發現透過OpenNMS自己夾帶的JMTA來發信 兩種機制。
    不論是透過哪一種機制來寄發郵件,均需修改以下路徑的設定檔來實現。
    /usr/share/opennms/etc/javamail-configuration.properties

    1. 若要使用25 port的mail server來發信,請將上述路徑的設定檔進行以下的調整。
      org.opennms.core.utils.fromAddress=YourAccount@yourdomain.com.tw
      org.opennms.core.utils.mailHost=yourdomain.com.tw
      #org.opennms.core.utils.mailer=smtpsend
      org.opennms.core.utils.transport=smtp
      #org.opennms.core.utils.debug=true
      org.opennms.core.utils.smtpport=25
      org.opennms.core.utils.smtpssl.enable=false
      #org.opennms.core.utils.quitwait=true
      org.opennms.core.utils.useJMTA=false
      org.opennms.core.utils.authenticate=true
      org.opennms.core.utils.authenticateUser=YourAccount
      org.opennms.core.utils.authenticatePassword=YourPassword
      org.opennms.core.utils.starttls.enable=false
      org.opennms.core.utils.messageContentType=text/plain
      org.opennms.core.utils.charset=UTF-8


    2. 若要使用GMail來發送信件,請進行以下的調整。
      #org.opennms.core.utils.fromAddress=root@[127.0.0.1]
      org.opennms.core.utils.mailHost=smtp.gmail.com
      #org.opennms.core.utils.mailer=smtpsend
      org.opennms.core.utils.transport=smtp
      #org.opennms.core.utils.debug=true
      org.opennms.core.utils.smtpport=587
      org.opennms.core.utils.smtpssl.enable=false
      #org.opennms.core.utils.quitwait=true
      org.opennms.core.utils.useJMTA=false
      org.opennms.core.utils.authenticate=true
      org.opennms.core.utils.authenticateUser=YourAccount@gmail.com
      org.opennms.core.utils.authenticatePassword=YourPassword
      org.opennms.core.utils.starttls.enable=true
      org.opennms.core.utils.messageContentType=text/plain
      org.opennms.core.utils.charset=UTF-8


    3. 若要使用OpenNMS自己夾帶的JMTA來發信,可進行以下的調整。
      org.opennms.core.utils.fromAddress=YourAccount@yourdomain.com.tw
      #org.opennms.core.utils.mailHost=127.0.0.1
      org.opennms.core.utils.mailer=smtpsend
      org.opennms.core.utils.transport=smtp
      #org.opennms.core.utils.debug=true
      org.opennms.core.utils.smtpport=25
      org.opennms.core.utils.smtpssl.enable=false
      org.opennms.core.utils.quitwait=true
      org.opennms.core.utils.useJMTA=true
      #org.opennms.core.utils.authenticate=false
      #org.opennms.core.utils.authenticateUser=opennms
      #org.opennms.core.utils.authenticatePassword=opennms
      #org.opennms.core.utils.starttls.enable=false
      #org.opennms.core.utils.messageContentType=text/plain
      #org.opennms.core.utils.charset=us-ascii

      其中fromAddress請輸入您合法的email以免被收信mail server判斷為非法垃圾郵件。

    若發信失敗,又不知道問題在哪?
    請取消參數 debug 的註解,並設定其值為 true 以開啟偵錯模式,發信的log則會儲存在以下路徑中。
    /usr/share/opennms/logs/notifd.log


  • 定義通告事件
    通告事件的定義可在 Admin / Configure Notifications / Event Notifications 中進行。
    可在此面頁中定義哪些事件需要通知?哪些不需要。


    *這個頁面比較特別,on/off按鈕按下去即生效,而非圈選後再按下儲存按鈕來做變更。


  • 收信人設定
    OpenNMS有使用者與群組概念,
    事件通知可寄發給個人,也可寄發給群組。

    不過不論寄發給個人或是群組,還是以個人為基礎。
    所以第一步先把使用者帳號的email建立起來吧!

    使用者的email帳號在 Admin / Users and Groups / User List 中,將user的email補齊吧∼




    接著設定哪些人?群組?或是email?需要收到通知信。
    這項設定是在 Admin / Configure Notifications / Destination Paths 中進行設定。
    對預設的 Email-Admin 進行編輯。





    然後在如下的畫面中,選擇要收到通知的使用者帳號或群組。
    若要通知特別的email,也可以直接在此畫面中輸入。





    於如下畫面中確認有勾選 JavaEmailon 兩個選項。



    最後按下 Finish 就完成囉∼




  • 開啟Notification功能
    這樣就可以成功寄發通知信件到指定的收件信箱了嗎?
    其實還沒有喔!
    注意到畫面右上方鈴鐺還是有紅色的禁止符號嗎?



    於 Admin 畫面中,圈選Notification為 On 然後按下Update按鈕,這樣就可以成功啟用email通知機制了∼



    右上方鈴鐺變成綠色
    OpenNMS的notification郵件通知機制到此設定完成∼



參考資料
Gmail example javamail-configuration.properties
OpenNMS HowTo Part4 -- OpenNMS configure Notification



♥順子老婆的網拍,請多關照∼

If you don't like something, change it.
If you can't change it, change your attitude.
Don't complain!




2015-10-13, 13:54 shunze 的個人資料 把 shunze 加入好友列表 發送Email給 shunze 瀏覽 shunze 的網站 MSN : shunze@gmail.com
  « 上一篇主題 下一篇主題 »
發表新主題 發表回覆
跳到:

Powered by: Burning Board 1.1.1 2001 WoltLab GbR