Groovy Script: alarm Object

When an Expression Rule of type Alarm, AlarmExtendedDataChange, AlarmSeverityChange or AlarmStateChange calls a Groovy script, the script is provided with the implicit object 'alarm'.  This example shows how the alarm object can be used.

This Expression Rule uses the CountAlarmsSinceHours Groovy script to check the number of alarms in the past number of hours, and escalate the alarm if more than three alarms have occurred:

IF     ExecuteCustomObject("CountAlarmsSinceHours", 1) < 3
THEN SetAlarmState("ACKNOWLEDGED", "Less than three alarms in the past hour")
ELSE  SetAlarmState("ESCALATED", "THREE OR MORE alarms in the past hour")
Here is the definition of the CountAlarmsSinceHours Groovy script.  The script uses the parameter 'hours' passed from the expression rule and the implicit object 'alarm'.  It returns the number of times the current alarm has occurred within 'hours' hours.