Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-4358

Make Node available to the Beanshell

    XMLWordPrintable

    Details

      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>

        Attachments

          Activity

            People

            Assignee:
            ranger Benjamin Reed
            Reporter:
            ajb Alex Bennee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: