Make Node available to the Beanshell

Description

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>

Acceptance / Success Criteria

None

Attachments

1
  • 20 Jan 2011, 01:22 PM

Lucidchart Diagrams

Activity

Show:

Benjamin Reed February 4, 2011 at 3:55 PM

Merged to master:

[master ca42d32] CBNL CORE: Make OnmsNode visible to the Scriptd beanshell

Fixed

Details

Assignee

Reporter

Labels

Fix versions

Affects versions

Priority

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

Flag notifications