`
mnfp20mnfp
  • 浏览: 17700 次
社区版块
存档分类
最新评论

OpenNMS扩展 - 事件配置

 
阅读更多

OpenNMS扩展 - 事件配置
2011年04月24日
  OpenNMS包括一个强有力的事件通知系统,OpenNMS管理事件通知的进程是eventd。主要有两种类型的事件:由OpenNMS内部产生的事件和通过外部的SNMP trap产生的事件。
  当事件产生时,将会设置不同的参数,比如:事件描述,事件的log信息与严重级别,另外,通过eventconf.xml文件配置能够自动加载事件发送参数到一个外部的script.
  OpenNMS的事件可以伴随一个通知,特别的事件可能通过页面或Email,SMS等方式发出一个通知。 事件配置的主要文件位于$OPENNMS_HOME/etc与$OPENNMS_HOME/etc/events目录下(本例OPENNMS_HOME为/usr/local/opennms/source/dist)。 这个文件定义通用事件识别码(Universal Event Identifiers或UEIs)以及它们的事件屏蔽(masks),描述,记录文件信息和严重程度。                                               logmsg                        operaction                        autoaction                        tticket                        script                      /usr/local/opennms/source/dist/etc/events/SureTech .events.xml /usr/local/opennms/source/dist/etc/events/3Com.eve nts.xml        /usr/local/opennms/source/dist/etc/events/Standard .events.xml                          MATCH-ANY-UEI                 OpenNMS defined event: MATCH-ANY-UEI                                          This UEI will never be generated, but exists                         so that notifications can match any UEI for a                         particular filter rule. Useful to see all events for                         a particular node via notifications.                                                                                    MATCH-ANY-UEI event.                                  Indeterminate          /usr/local/opennms/source/dist/etc/events/default. events.xml  eventconf.xml包括内部事件与外部事件的配置,内部事件主要是OpenNMS的事件,外部事件是自定义的事件,如企业事件。外部事件主要是通过标签引入。如引入SureTech企业的外部事件: /usr/local/opennms/source/dist/etc/events/SureTech .events.xml 所有的事件由企业分开。当opennms启动时,每个企业事件配置文件会被载入,根据引入文件选择顺序载入,定义在eventconf.xml文件中的事件会被事先加载。最佳实践是将内部事件定义在eventconf.xml中。
  注:在eventconf.xml最底端: /usr/local/opennms/source/dist/etc/events/default. events.xml 这个文件包含通用缺省事件,要始终列在最后。
  这个文件定义SNMP trap的埠口(port)。   这个文件定义eventd的运行参数,TCP,UDP端口,监听执行的线程数,下一个事件ID,Socket是否设置超时及超时时间。   在事件(events)产生时所呼叫的外部程序称为(actions). 此文件设置控制最多可以同时执行的action数量, 以及等待action执行完毕回传结果的逾时值。           Event模块日志配置。 如:建立SureTech.events.xml                                                                                            id                                  .1.3.6.1.4.1.888.1                                                                                  generic                                  6                                                                                  specific                                  1                                                                              uei.opennms.org/vendor/SureTech/traps/SureTechCPUR esourcesConsuemed                                                      SureTech-MIB defined trap event:                        SureTechCPUResourcesExceedConsuemed                                                      An ECC single-bit error has been corrected in one                        of the memory modules                                                      SureTech Event: EEC Single-bit Error                        Corrected.                              Normal                                                                                     id                                  .1.3.6.1.4.1.888.%                                                                                  generic                                  6                                                                              uei.opennms.org/vendor/SureTech/traps/EnterpriseDe fault                                                      OpenNMS-defined trap event: SureTech EnterpriseDefault                                                      This is the default event format used when an                        enterprise specific event (trap) is received from a SureTech                        device for which no format has been configured (i.e. no                        event definition exists).                                                      Received unformatted enterprise event (enterprise:%id%                        generic:%generic% specific:%specific%). %parm[##]% args:                        %parm[all]%                              Indeterminate        事件文件以标记开始以标记结束。
  标签的值可能有如下值:
  l         uei 
  l         source 
  l         host 
  l         snmphost 
  l         nodeid 
  l         interface 
  l         service 
  l         id 
  l         specific 
  l         generic 
  l         community 
  例子中的menname是取id,即企业OID=.1.3.6.1.4.1.888.1,generic值为6表现根据企业特定的MIB即1来产生事件。
  Generic是trap类型,共分为表4中的7种。 trap类型 名字 说明 0 coldStart 代理进行了初始化 1 warmStart 代理进行了重新初始化 2 linkDown 一个接口从工作状态变为故障状态 3 Linkup 一个接口从故障状态变为工作状态 4 authenticationFailure 从SNMP管理进程接收到具有一个无效共同体的报文 5 egpNeighborLoss 一个EGP相邻路由器变为故障状态 6 enterpriseSpecific 代理自定义的事件,需要用后面的"特定代码"来指明 当使用上述类型2、3、5时,在报文后面变量部分的第一个变量应标识响应的接口。
  Specific,是企业特定代码(specific-code),指明代理自定义的时间(若trap类型为6),否则为0。
  每一个企业事件配置文件中必须要全局事件放置最后,uei以定义企业的事件标签命名"路径",如:                         uei.opennms.org/vendor/SureTech/traps/EnterpriseDe fault                mask value可以使用"%"通配符表示所有的企业事件,如配合所有的SureTech(企业OID为.1.3.6.1.4.1.888)事件:                                                                         id                                  .1.3.6.1.4.1.888.%                                                                                  generic                                  6                                        eventd进程侦听端口5817 ,所以其他进程,甚至那些外部OpenNMS ,可以发送事件到系统中。该标记表示,这些事件不能凌驾于行动的定义在eventconf.xml文件。这样,没有人有权限通过打开"autoaction"进入该OpenNMS机器,也就是说,以root权限在这个机器上才能自动发送事件权利。
  本例子中,可通过snmptrap -v 2c -c public 192.168.6.13 "" .1.3.6.1.4.1.888.1.1 在Agent向Manager发送一个SNMP Trap,这样就会在Manager上产生一个SureTech自定义的事件。
  如下图所示:
  
  OpenNMS内部事件定义在eventconf.xml文件中,例如一个共同的事件: nodelostservice :    http://uei.opennms.org/nodes/nodeLostService   OpenNMS-defined node event: nodeLostService        A %service% outage was identified on interface     %interface%. A new Outage record has been     created and service level availability calculations will be     impacted until this outage is resolved.                 %service% outage identified on interface %interface%.      Major  每一事件以标记来定义。这个标记里面有不同的定义:
  uei 
  "通用事件标识符",用来唯一标识一个事件。注意:对于内部opennms的事件, uei直接由代码产生而不能修改。
  event-label
  以纯文本的方式对事件加标签,有时被用来在网页的用户界面。
  descr 
  事件描述。可以嵌入HTML,如果您希望格式的描述更充分。请注意,有要素,如%interface% ,你就可以在该事件描述和日志消息。
  logmsg 
  事件简短的描述或概要的说明。 "dest"属性,可以如下值:
  l         logndisplay 记录事件在数据库中并在Web UI中显示。
  l         logonly 记录事件在数据库中,但不显示它。
  l         suppress 既不在数据库记录事件又不显示它。
  l         donotpersist 不记录事件在数据库中,但仍然将它传送至opennms的后台程序是监听针对此类型的活动(例如:这可以用来产生通知)。
  l         discardtraps 这仅适用于陷阱。这将导致trapd抛弃的陷阱,没有创造一个事件。其他opennms的后台程序是监听针对此类型的事件将不会收到此事件。这项功能是第一个可用在opennms 1.3.0 。
  severity 
  表示事件的级别。 Critical This event means numerous devices on the network are affected by the event. Everyone who can should stop what they are doing and focus on fixing the problem. Major A device is completely down or in danger of going down. Attention needs to be paid to this problem immediately. Minor A part of a device (a service, and interface, a power supply, etc.) has stopped functioning. The device needs attention. Warning An event has occurred that may require action. This severity can also be used to indicate a condition that should be noted (logged) but does not require direct action. Normal Informational message. No action required. Cleared This event indicates that a prior error condition has been corrected and service is restored Indeterminate No Severity could be associated with this event. 各种元素可以包括在每一个事件的说明,日志信息,操作说明和自动动作中。并非所有的事件将有元素的值,有些是指SNMP trap。
  %uei%  
  The UEI for the event. 
  %source%  
  The source of the event (what process). 
  %time%  
  The time of the event. 
  %nodeid%  
  The node ID of the device that caused the event. 
  %interface%  
  The interface associated with the event. 
  %service%  
  The service associated with the event. 
  %severity%  
  The severity of the event. 
  %snmphost%  
  The host of the SNMP agent that generated the event. 
  %snmp%  
  The SNMP information associated with the event. 
  %id%  
  The SNMP Enterprise OID for the event. 
  %generic%  
  The Generic trap number for the event. 
  %specific%  
  The Specific trap number for the event. 
  %community%  
  The community string for the trap. 
  %version%  
  The SNMP version of the trap.  
  %operinstruct%  
  The operator instructions for the event. 
  %mouseovertext%  
  The mouse over text for the event. 
  In version 1.1 and beyond, there are two more parameters available: 
  %nodelabel%  
  Returns the node label for the node given in %nodeid% if available. 
  %interfaceresolv%  
  Does a reverse lookup on the %interface% and returns its name if available. 除了OpenNMS内部产生事件外,OpenNMS还可以接收SNMP Traps透过trapd进程。这些都是使用标记控制在eventconf.xml文件中(例如:2.1.5自定义事件文件)。这就是与内部事件配置主要的不同之处 一些事件,特别是SNMP Traps,有额外的信息发送给他们即所谓的"variable bindings"或"varbinds"。在ciscoc3800sysaggregatestatuschange事件上面列出的,有四个的他们,他们可以使用parm元素访问。每个参数由一个名称和一个值构成。
  %parm[all]%  
  Will return a space-separated list of all parameter values in the form parmName1="parmValue1" parmName2="parmValue2" etc. 
  %parm[values-all]%  
  Will return a space-separated list of all parameter values associated with the event. 
  %parm[names-all]%  
  Will return a space-separated list of all parameter names associated with the event. 
  %parm[]%  
  Will return the value of the parameter named  if it exists. 
  %parm[##]%  
  Will return the total number of parameters. 
  %parm[#]%  
  Will return the value of parameter number .
  每一个事件产生后将会添加到数据库中的events表中。Web UI通过Servlet提交要查询的event返回到Web UI供客户端显示。
  注:配置事件相关的XML文件后需重启OpenNMS.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics