Проблема автоматизации OpenNMS - невозможно использовать результаты SQL из триггера в действии
Я пытаюсь создать автоматизацию, которая будет подтверждать ошибки через x секунд в OpenNMS.
Я настроил автоматизацию, как это в Vacumd.xml
<!-- Custom acknowledgement manager - We unacknowledged acknowledged alarms -->
<automation name="acknowledgement_manager" interval="60000" active="true"
trigger-name="acknowledgement_manager_trigger"
action-name="acknowledgement_manager_action"
action-event="acknowledgement_manager_event" />
<trigger name="acknowledgement_manager_trigger" operator=">=" row-count="1" >
<statement>
select alarmId AS _alarmid, nodeId AS _nodeid
from alarms
WHERE alarmacktime is not NULL
and alarmackuser is not NULL
</statement>
</trigger>
<action name="acknowledgement_manager_action" >
<statement>
UPDATE alarms set alarmacktime = NULL, alarmackuser = NULL
where alarmid = ${_alarmid} and nodeid = ${_nodeid}
</statement>
</action>
<action-event name="acknowledgement_manager_event">
<assignment type="field" name="uei" value="mottmac.com/opennms/information" />
<assignment type="field" name="nodeid" value="${_nodeid}" />
<assignment type="field" name="service" value="alarms" />
<assignment type="parameter" name="logmsg" value="The system has automaticly unacknowledged an alarm which was incorrectly acknowledged with alarm id ${alarmid}" />
<assignment type="parameter" name="descr" value="The system has automaticly unacknowledged an alarm which was incorrectly acknowledged with alarm id ${alarmid}" />
</action-event>
Я знаю, что SQL в триггере возвращает 1 строку с alarmid и nodeid, однако при выполнении действия я получаю следующее сообщение об ошибке:
2018-11-30 10:54:14,130 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor: runAutomation: Executing trigger: acknowledgement_manager_trigger
2018-11-30 10:54:14,130 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.Transaction: About to begin Transaction for Thread[Vacuumd-Thread-2-of-2,5,main]
2018-11-30 10:54:14,130 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.Transaction: Began Transaction for Thread[Vacuumd-Thread-2-of-2,5,main]
2018-11-30 10:54:14,130 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor: runAutomation: Processing automation: acknowledgement_manager
2018-11-30 10:54:14,131 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor: verifyRowCount: Verifying trigger result: 1 is >= than 1
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$TriggerProcessor: triggerRowCheck: Verifying trigger resulting row count 1 is >= 1
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$TriggerProcessor: Row count verification is: true
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor: runAutomation: running action(s)/actionEvent(s) for : acknowledgement_manager
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: getTokenizedColumns: processing string:
UPDATE alarms set alarmacktime = NULL, alarmackuser = NULL
where alarmid = ${_alarmid} and nodeid = ${_nodeid}
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: getTokenizedColumns: Token 1: _alarmid
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: getTokenizedColumns: Token 2: _nodeid
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: resultSetHasRequiredActionColumns: Verifying required action columns in trigger ResultSet...
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-1-of-2] c.z.h.p.PoolBase: opennms - Reset (autoCommit) on connection org.postgresql.jdbc.PgConnection@539ea072
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: createPrepareStatement: This action SQL:
UPDATE alarms set alarmacktime = NULL, alarmackuser = NULL
where alarmid = ${_alarmid} and nodeid = ${_nodeid}
Turned into this:
UPDATE alarms set alarmacktime = NULL, alarmackuser = NULL
where alarmid = ? and nodeid = ?
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-1-of-2] o.o.n.v.Transaction: Committed transaction for Thread[Vacuumd-Thread-1-of-2,5,main]
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-1-of-2] o.o.n.v.AutomationProcessor: runAutomation: Sending 0 events for automation: clearPathOutages
2018-11-30 10:54:14,133 DEBUG [Vacuumd-Thread-1-of-2] o.o.n.v.AutomationProcessor: runAutomation: Done processing automation: clearPathOutages
2018-11-30 10:54:14,132 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: getTokenizedColumns: processing string:
UPDATE alarms set alarmacktime = NULL, alarmackuser = NULL
where alarmid = ${_alarmid} and nodeid = ${_nodeid}
2018-11-30 10:54:14,133 DEBUG [Vacuumd-Thread-1-of-2] o.o.n.v.AutomationProcessor: run: Finished automation clearPathOutages, started at 2018-11-30T10:54:14.129+0000
2018-11-30 10:54:14,133 DEBUG [Vacuumd-Thread-1-of-2] o.o.n.s.LegacyScheduler: schedule: Adding ready runnable ScheduleEntry[expCode=1] for org.opennms.netmgt.vacuumd.AutomationProcessor@30c99862 (ready in 30000ms) at interval 30000
2018-11-30 10:54:14,133 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: getTokenizedColumns: Token 1: _alarmid
2018-11-30 10:54:14,133 DEBUG [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor$ActionProcessor: getTokenizedColumns: Token 2: _nodeid
2018-11-30 10:54:14,133 DEBUG [Vacuumd-Thread-1-of-2] o.o.n.s.LegacyScheduler: schedule: queue element added, notification not performed
2018-11-30 10:54:14,134 WARN [Vacuumd-Thread-2-of-2] o.o.n.v.AutomationProcessor: runAutomation: Could not execute automation: acknowledgement_manager
java.lang.IllegalArgumentException: token _nodeid is not allowed for org.opennms.netmgt.vacuumd.AutomationProcessor$InvalidSymbolTable@29c3329b when no trigger is being processed
at org.opennms.netmgt.vacuumd.AutomationProcessor$InvalidSymbolTable.getSymbolValue(AutomationProcessor.java:502) ~[opennms-services-23.0.1.jar:?]
at org.opennms.core.utils.PropertiesUtils.substitute(PropertiesUtils.java:161) ~[org.opennms.core.lib-23.0.1.jar:?]
at org.opennms.core.utils.PropertiesUtils.substitute(PropertiesUtils.java:140) ~[org.opennms.core.lib-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor$EventAssignment.assign(AutomationProcessor.java:518) ~[opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor$ActionEventProcessor.buildEvent(AutomationProcessor.java:575) ~[opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor$ActionEventProcessor.getEvent(AutomationProcessor.java:564) ~[opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor$ActionEventProcessor.processActionEvent(AutomationProcessor.java:628) ~[opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor.processAction(AutomationProcessor.java:758) ~[opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor.runAutomation(AutomationProcessor.java:726) [opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.vacuumd.AutomationProcessor.run(AutomationProcessor.java:684) [opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.scheduler.Schedule.run(Schedule.java:142) [opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.scheduler.Schedule$ScheduleEntry.run(Schedule.java:86) [opennms-services-23.0.1.jar:?]
at org.opennms.netmgt.scheduler.LegacyScheduler$1.run(LegacyScheduler.java:179) [opennms-services-23.0.1.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_45]
at org.opennms.core.concurrent.LogPreservingThreadFactory$3.run(LogPreservingThreadFactory.java:124) [opennms-util-23.0.1.jar:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_45]
Похоже, что nodeid/alarmid не заполняется для обновления?
Спасибо за любую помощь
Джо.