Fixed
Details
Assignee
Benjamin ReedBenjamin ReedReporter
Alex BenneeAlex BenneeLabels
Components
Fix versions
Affects versions
Priority
Minor
Details
Details
Assignee
Benjamin Reed
Benjamin ReedReporter
Alex Bennee
Alex BenneeLabels
Components
Fix versions
Affects versions
Priority
PagerDuty
PagerDuty
PagerDuty
Created January 20, 2011 at 1:22 PM
Updated January 27, 2017 at 4:19 PM
Resolved February 4, 2011 at 3:55 PM
From commit:
CBNL CORE: Make OnmsNode visible to the Scriptd beanshell
In my use case for scripting (generating snmp trap events on certain
nodes going up and down) I need to know what those nodes are. This
patch exports the OnmsNode to the beanshell so more refined scripting
can be done.
Example usage:
<event-script language="beanshell">
<uei name="uei.opennms.org/nodes/nodeDown"/>
event=bsf.lookupBean("event");
log.debug("filtered event-script:"+event.uei);
node=bsf.lookupBean("node");
if (node != null) {
String foreignId = node.getForeignId();
if (foreignId != null) {
if (foreignId.contains("APC")) {
log.debug("Processing APC "event.host" event: "event.uei" @ "+event.time);
String params = "--down "+foreignId;
log.debug("Script: "+params);
exec("/usr/local/vectastar/bin/vsnorthtrap.pl "+params);
}
}
} else {
log.warn("CBNL nodeDown Trap Script not passed a node");
}
</event-script>