OpenNMS擴展 - SMS通知
1. 概述(Overview)
OpenNMS事件產生後,通過相應的配置,可以通過SMS告知事件。
通知能夠發送到用戶、組及任何合法的SMS PIN。短信包含文字信息,文字信息可以根據特定的事件進行定製,比如可以定製節點的名字,IP地址,服務名,錯誤信息等等。
2. SMS Server Tool配置
SMS Server Tool 見《Configure GSM Send SMS Guide》文檔。
在配置好SMS Server Tool後,在命令行測試是否可以發送:i.e. sendsms <mobile#> ‘text message’,如果可以,則進行OpenNMS SMS配置。
3. SMS通知配置(SMS Configuration)
爲了給相應的用戶發送SMS通知,用戶需要設置一個合法的Numeric PIN,針對admin用戶,設置Numeric PIN的步驟:以admin身份登錄,進入菜單Admin ->設置Notification Status爲On,單擊Update按鈕-> 進入Configure Users and Groups->Configure Users->單擊Modify修改用戶信息,填寫用戶合法Numeric PIN,如:8613662265481,單擊Finish保存完成設置。
2.1 配置文件(Configuration File)
通知通過守護進程“notifd”進行處理。這個守護進程默認情況下通過destinationPaths.xml,notifd-configuration.xml與notifications.xml三個配置文件運行管理,而三個配置文件的內容可以通知Web UI來進修改設置,最主要的配置是notificationCommands.xml,此文件是SMS的入口。
2.1.1 destinationPaths.xml
設定目標路徑,指定誰得到任何通知和擴展(escalations),如下是使用smsgw建立一個destinationPaths的例子。
<path name="SMS-L1" initial-delay="1s">
<target interval="0s">
<name xmlns="">l1-support</name>
<autoNotify xmlns="">auto</autoNotify>
<command xmlns="">javaEmail</command>
</target>
<escalate delay="30s">
<target interval="0m">
<name xmlns="">DaySupportDesk</name>
<autoNotify xmlns="">auto</autoNotify>
<command xmlns="">smsgw</command>
</target>
</escalate>
<escalate delay="5m">
<target interval="0m">
<name xmlns="">NightSupportDesk</name>
<autoNotify xmlns="">auto</autoNotify>
<command xmlns="">smsgw</command>
</target>
</escalate>
</path>
2.1.2 notifd-configuration.xml
爲通知守護進程配置全局屬性,如:處理事件隊列和自動發現(映射“下降”的事件與“向上”的事件,自動發現事件,承認(acknowledge)通知,無需執行更多的擴展)。
2.1.3 notifications.xml
實際配置的通知。配置發送通知IP地址過濾規則,目標路徑及主題與內容信息,如下表示一個結點down時的通知配置:
<notification name="nodeDown" status="on">
<uei>uei.opennms.org/nodes/nodeDown</uei>
<rule>IPADDR IPLIKE *.*.*.*</rule>
<destinationPath>Email-Admin</destinationPath>
<text-message>All services are down on node %nodelabel%. New Outage records have
been created and service level availability calculations will
be impacted until this outage is resolved.
</text-message>
<subject>Notice #%noticeid%: node %nodelabel% down.</subject>
<numeric-message>111-%noticeid%</numeric-message>
</notification>
2.1.4 notificationCommands.xml
定義如何達成在destinationPaths.xml中所使用的各種配置通知方式. 如Email,Java Mail,頁面, XMPP協議, SNMP陷阱等,Java的通知方式通常是首選,因爲他們有更高的性能,更重要的低開銷比調用一個外部程序。最通知方式實施這種方式。一個標準的接口存在, org.opennms.netmgt.notifd.notificationstrategy ,可以用來執行定製的Java通知方式。當然,通過命令行程序和shell腳本也是允許的。
,此文件包括了可執行文件的所在位置, 各種聯絡方式的別名(aliases), 以及特定傳送方式尚需的其它信息等。
<command binary="true">
<name>smsgw</name>
<execute>/usr/local/bin/sendsms</execute>
<comment>for sending GSM SMS notifications</comment>
<argument streamed="false">
<switch>-np</switch>
</argument>
<argument streamed="false">
<switch>-tm</switch>
</argument>
</command>
說明:
1. <command binary="true">,表示發送短信是以命令行的方式(/usr/local/bin/sendsms)來執行。
2. <argument streamed="false">,表示發送的短信不以流的方式發送,即如果短信長度超出範圍,會分幾條發送。
注:相關的XML配置文件修改後需重啓OpenNMS才能生效。