Automations

From OpenNMS

As of version 1.3, OpenNMS provides you with a more robust solution by automating its behavior to meet the requirements of your business or organization. For example, say you have an alarm with the severity of "Minor" that has not been acknowledged in the last twenty minutes - you might want to escalate the severity.

OpenNMS has a daemon that runs SQL statements on an interval called Vacuumd. Its configuration has been enhanced with a configuration that now allows configuration of processes we're calling Automations that are defined by Triggers and Actions.

Contents

Automation attributes

An automation is made up of trigger and actions statments that can query and update tables in the OpenNMS database (the next release will allow processing of external databases). The OpenNMS automation is defined with the following attributes (ones marked with a "*" are required):

name (*) 
A string that identifies the automation
interval (*) 
An integer specifying, in milliseconds, how often to run the automation
trigger-name 
A string that references a trigger by its name attribute
action-name (*) 
A string that references an action by its name attribute

Triggers

A trigger is defined with 3 attributes and an SQL statement. The trigger's statement is designed to be an SQL DQL select statement. The results of the query are analyzed and processed by the action statement.

A trigger has the following attributes (ones marked with a "*" are required):

name 
String identifying the name of the trigger referenced by the automation attribute 'trigger-name'
row-count 
Used with the operator attribute to determine if the action should be executed
operator 
Used with the row-count attribute to determine if the action should be executed

Actions

The action, unlike a trigger, is required for an automation. Its SQL is designed to be a DML statement that can be executed against the result set of an automation or it can be excuted independently.

Actions that process trigger results will usually require access to the data from the columns specified in the DQL statement. To access this column data, specify the column using the format '${<column name>}'. For example, to update the severity for of all alarms returned in the result of a trigger (an esclation):

UPDATE alarms SET severity = least(7, severity+1)
 WHERE alarmid = ${alarmid}
   AND alarmAckUser is NULL

OpenNMS' AutomationProcessor class will analyze this statement and verify that the result set contains the required columns and will execute the update.

vacuumd-configuration.xml

Below, is a sample Vacuumd configuration file with examples for the old formatted statements as well as the new automation feature.

<VacuumdConfiguration period="86400000" >
  <statement>
     DELETE FROM node WHERE node.nodeType = 'D';
  </statement>

    <automations>
<!-- These are not fully tested -->
           <automation name="autoEscalate" interval="10000" trigger-name="selectWithCounter" auto-event-name="escalationEvent" action-name="escalate" active="true" />
           <automation name="cleanUpAlarms" interval="300000" action-name="deleteDayOldAlarms" active="true" />
           <automation name="cosmicClear" interval="30000" trigger-name="selectResolvers" action-name="clearProblems" active="true" />
    </automations>
    <triggers>
           <trigger name="selectAll" operator=">=" row-count="1" >
               <statement>SELECT * FROM alarms</statement>
           </trigger>
           <trigger name="selectWithCounter" >
               <statement>SELECT alarmid FROM alarms WHERE counter >= 2</statement>
           </trigger>
                  <trigger name="selectResolvers" operator=">=" row-count="1" >
                      <statement>SELECT * FROM alarms WHERE alarmType=2</statement>
          </trigger>
    </triggers>
    <actions>
           <action name="clear" >
               <statement>UPDATE alarms SET severity=2 WHERE alarmid = ${alarmid}</statement>
           </action>
           <action name="clearProblems" >
               <statement>UPDATE alarms SET severity=2 WHERE alarmType=1 AND lastEventTime <=  ${lastEventTime} AND severity > 2 AND eventUei = ${clearUei} AND dpName = ${dpName} and nodeID = ${nodeID} and ipaddr = ${ipaddr} and serviceID = ${serviceID}</statement>
               <!-- <statement>UPDATE alarms SET severity=2 WHERE alarmType=1 AND severity > 2 AND dpName = ${dpName} and nodeID = ${nodeID} and ipaddr = ${ipaddr} and serviceID = ${serviceID}</statement> -->
           </action>
           <action name="escalate" >
               <statement>UPDATE alarms SET severity = severity+1 WHERE alarmid = ${alarmid} and severity < 7 and alarmAckUser is null</statement>
           </action>
           <action name="delete" >
               <statement>DELETE FROM alarms WHERE nodeid = ${nodeid} and eventuei = ${eventuei}</statement>
           </action>
           <action name="deleteDayOldAlarms" >
               <statement>DELETE FROM alarms WHERE alarmAckUser IS NOT NULL AND lastEventTime < CURRENT_TIMESTAMP</statement>
           </action>
    </actions>
    <auto-events>
        <auto-event name="escalationEvent" >
            <uei>uei.opennms.org/vacuumd/alarmEscalated</uei>
        </auto-event>
    </auto-events>

</VacuumdConfiguration>

See also Alarms.

If you need to add information or transform events when they are created, you should have a look at Event_Translator.

Personal tools
DevJam 2008 Sponsors
DevJam 2008 Sponsor: Google
DevJam 2008 Sponsor: Netregistry
DevJam 2008 Sponsor: Papa John's
NewEdge Networks
OpenNMS takes home the gold award!
Join the Free Software Foundation
Support This Project Commercial OpenNMS Support OpenNMS Italia Get OpenNMS at SourceForge.net. Fast, secure and Free Open Source software downloads Our Network Simulator Our Java Profiler