From OpenNMS
Similar to Actiond, generates external actions based on events received. Scriptd has not been refactored or instrumented for testing as of May 12, 2005.
Description
Scriptd allows the user to configure Bean Shell [1] script to run in response to events. You can either run a script on every single event or set up filtered scripts that only run on certain events. Bean Shell provides a Java like scripting language with a familiar syntax.
Available Beans
Currently there is only one available bean representing the event which can be loaded with:
event=bsf.lookupBean("event");
Patches exist for adding the relevant node to the list.
Examples
Scripts can be one of the following:
- Attached Scripts (attached to event description *I think*?)
- UEI mapped scripts (attached to a given event UEI)
- Global scripts (run for every event in the system)
- See HP OpenView Integration for a good example
- The following example gives you a good basis for the majority of information available on the event and will send it to log4j.
<?xml version="1.0"?>
<scriptd-configuration>
<engine language="beanshell" className="bsh.util.BeanShellBSFEngine" extensions="bsh"/>
<start-script language="beanshell">
log = bsf.lookupBean("log");
</start-script>
<stop-script language="beanshell">
log.error("executing a stop script");
</stop-script>
<event-script language="beanshell">
<uei name="com.company.uei/testTrap" />
event = bsf.lookupBean("event");
a = new Hashtable();
a{"dbid"} = event.dbid;
a{"uei"} = event.uei;
a{"creationTime"} = ( event.creationTime != null ? event.creationTime : "na" );
a{"descr"} = ( event.descr != null ? event.descr : "na" );
a{"distPoller"} = ( event.distPoller != null ? event.distPoller : "na" );
a{"host"} = ( event.host != null ? event.host : "na" );
a{"ifAlias"} = ( event.ifAlias != null ? event.ifAlias : "na" );
a{"ifIndex"} = ( event.ifIndex != null ? event.ifIndex : "na" );
a{"interface"} = ( event.getInterface() != null ? event.getInterface() : "na" );
a{"masterStation"} = ( event.masterStation != null ? event.masterStation : "na" );
a{"mouseOverText"} = ( event.mouseovertext != null ? event.mouseovertext : "na" );
a{"nodeid"} = ( event.nodeid != null ? event.nodeid : "na" );
a{"pathoutage"} = ( event.pathoutage != null ? event.pathoutage : "na" );
a{"service"} = ( event.service != null ? event.service : "na" );
a{"severity"} = ( event.severity != null ? event.severity : "na" );
a{"snmpHost"} = ( event.snmphost != null ? event.snmphost : "na" );
a{"source"} = ( event.source != null ? event.source : "na" );
a{"time"} = ( event.time != null ? event.time : "na" );
a{"uuid"} = ( event.uuid != null ? event.uuid : "na" );
parms = event.parms;
log.info(a.toString());
if (parms != null){
log.info(parms.getParm(1).value.content);
for(parm : parms.getParm()){
log.info( parm.parmName + "=" + parm.value.content );
}
}
</event-script>
</scriptd-configuration>






