OpenNMS扩展 - 事件通知

来源:互联网 发布:电脑激活windows 编辑:程序博客网 时间:2024/05/09 05:29

OpenNMS扩展 - 事件通知

1.     概述(Overview

OpenNMS事件产生后,通过相应的配置,通过通知告知事件。一般的通知方式主要用Email、页面,但通知的机制也存在如下情况:

l         XMPP协议(Jabber ,一种即时通讯协议) 

l         任意外部程序

l         SNMP Trap

l         任意的HTTP GETs/POSTs

通知能够发送到用户、组及任何合法的Email地址。通知本身包含文字信息和主题,文字信息与主题可以根据特定的事件进行定制,比如可以定制节点的名字,IP地址,服务名,错误信息等等。

为了给相应的用户发送事件通知,用户需要设置一个合法的Email,针对admin用户,设置Email步骤:以admin身份登录,进入菜单Admin ->设置Notification StatusOn,单击Update按钮-> 进入Configure Users and Groups->Configure Users->单击Modify修改用户信息,填写用户合法Email地址,单击Finish保存完成设置。

2.     通知配置(Notification Configuration

2.1 配置文件(Configuration File

通知通过守护进程“notifd”进行处理。这个守护进程默认情况下通过destinationPaths.xmlnotifd-configuration.xmlnotifications.xml三个配置文件运行管理,而三个配置文件的内容可以通知Web UI来进修改设置。

2.1.1 destinationPaths.xml 

设定目标路径,指定谁得到任何通知和扩展(escalations)。

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="false">

        <name>javaEmail</name> <execute>org.opennms.netmgt.notifd.JavaMailNotificationStrategy</execute>

        <comment>class for sending email notifications</comment>

        <argument streamed="false">

            <switch>-subject</switch>

        </argument>

        <argument streamed="false">

            <switch>-email</switch>

        </argument>

        <argument streamed="false">

            <switch>-tm</switch>

        </argument>

    </command>

    

2.2 Java Mail配置

       OpenNMS中的Java Mail采用了Sun JavaMail API ,利用些API可以创建邮件用户代理,通过一个默认的帐户发送通知给客户,Java Mail的配置包含在$OPENNMS_HOME/etc/javamail-configuration.properties文件中。

2.2.1 javamail-configuration.properties.xml

###############################################################################

#

# This file is the configuration for the the JavaMailer class.  It is used to

# specify the details of the JavaMailer system properties

###############################################################################

#

#

# Properties are defined but commented out indicating the default values.

#

 

#

# This property defines system sender account.

#

# The default setting is root@[127.0.0.1]

org.opennms.core.utils.fromAddress=support@suretech.com.hk

 

#

# This property defines SMTP Host.

#

org.opennms.core.utils.mailHost=stmail.suretech.com

org.opennms.core.utils.mailer=smtpsend

org.opennms.core.utils.transport=smtp

org.opennms.core.utils.debug=true

#

# This property defines Mail authentication.

# The default setting is false

org.opennms.core.utils.authenticate=true

org.opennms.core.utils.authenticateUser=jacky

org.opennms.core.utils.authenticatePassword=suretech

 

# This property controls the use of the JMTA, the

# default is true

org.opennms.core.utils.useJMTA=false

配置系统采用用户jacky来发送Email.而用户收到的显示发送人为support@suretech.com.hk

为了保障信息安全,用户也可以在Linux下架设自己的Email Server,如SendMail,然后将进行相应的设置。

       注:配置事件相关的XML文件后需重启OpenNMS

 

原创粉丝点击