<trigger name="selectEmergencyF0NodeAlarms" operator=">=" row-count="1" >
<statement>
SELECT a.alarmid AS _alarmid,
now() AS _ts
FROM alarms a
LEFT JOIN category_node cn
ON cn.nodeid = a.nodeid
LEFT JOIN categories ca
ON ca.categoryid = cn.categoryid
WHERE ( a.eventuei = 'uei.opennms.org/nodes/nodeDown'
OR a.eventuei = 'uei.opennms.org/nodes/interfaceDown')
AND ca.categoryname = 'EMERGENCY_F0'
AND severity > 3
AND severity < 7
</statement>
</trigger>
I think we may need to patch alarmd with something like:
diff --git a/opennms-alarms/daemon/src/main/java/org/opennms/netmgt/alarmd/drools/DroolsAlarmContext.java b/opennms-alarms/daemon/src/main/java/org/opennms/netmgt/alarmd/drools/DroolsAlarmContext.java
index a919bedf56c..2a37a82299c 100644
--- a/opennms-alarms/daemon/src/main/java/org/opennms/netmgt/alarmd/drools/DroolsAlarmContext.java
+++ b/opennms-alarms/daemon/src/main/java/org/opennms/netmgt/alarmd/drools/DroolsAlarmContext.java
@@ -381,6 +381,10 @@ public class DroolsAlarmContext extends ManagedDroolsContext implements AlarmLif
// The last event may be null in unit tests
Hibernate.initialize(alarm.getLastEvent().getEventParameters());
}
+ if (alarm.getNode() != null) {
+ // Allow rules to use the categories on the associated node
+ Hibernate.initialize(alarm.getNode().getCategories());
+ }
final AlarmAndFact alarmAndFact = alarmsById.get(alarm.getId());
in order to allow for the categories to be accessible and not throw lazy initialization exceptions.
Example automation we would like to accomplish with Drools rules:
<automation name="escalationEMERGENCYF0" interval="30000" active="true" trigger-name="selectEmergencyF0NodeAlarms" action-name="escalateAlarm" action-event="sendAlarmEscalatedEvent" />
<trigger name="selectEmergencyF0NodeAlarms" operator=">=" row-count="1" > <statement> SELECT a.alarmid AS _alarmid, now() AS _ts FROM alarms a LEFT JOIN category_node cn ON cn.nodeid = a.nodeid LEFT JOIN categories ca ON ca.categoryid = cn.categoryid WHERE ( a.eventuei = 'uei.opennms.org/nodes/nodeDown' OR a.eventuei = 'uei.opennms.org/nodes/interfaceDown') AND ca.categoryname = 'EMERGENCY_F0' AND severity > 3 AND severity < 7 </statement> </trigger>