From OpenNMS
Here at BurlingtonTelecom, we've created a small perl script, mibmaker.pl to create OpenNMS events.xml files from a delineated list of varbinds. We hope that it might be of some help to others in the OpenNMS community.
Overview
The basic idea was to take a list of traps and the corresponding varbinds and create a events.xml files from them.
This is a sample of the input file that we used to lead the mibmaker.pl script.
remoteAlarmIndication,98:ifDs0Port,2:nearEnd,1:cleared,1 remoteAlarmIndication,98:ifDs0Port,2:nearEnd,1:standing,2 remoteAlarmIndication,98:ifDs0Port,2:nearEnd,1:transient,3 remoteAlarmIndication,98:ifDs0Port,2:nearEnd,1:notApplicable,4 remoteAlarmIndication,98:ifDs0Port,2:farEnd,2:cleared,1 remoteAlarmIndication,98:ifDs0Port,2:farEnd,2:standing,2 remoteAlarmIndication,98:ifDs0Port,2:farEnd,2:transient,3 remoteAlarmIndication,98:ifDs0Port,2:farEnd,2:notApplicable,4 remoteAlarmIndication,98:ifDs0Port,2:bothEnds,3:cleared,1 remoteAlarmIndication,98:ifDs0Port,2:bothEnds,3:standing,2 remoteAlarmIndication,98:ifDs0Port,2:bothEnds,3:transient,3 remoteAlarmIndication,98:ifDs0Port,2:bothEnds,3:notApplicable,4 remoteAlarmIndication,98:ifDs0Port,2:notApplicable,4:cleared,1 remoteAlarmIndication,98:ifDs0Port,2:notApplicable,4:standing,2 remoteAlarmIndication,98:ifDs0Port,2:notApplicable,4:transient,3 remoteAlarmIndication,98:ifDs0Port,2:notApplicable,4:notApplicable,4
The pattern we chose was nothing special, just text and the corresponding varbind number separated by a comma ,.
Trap,Trap#
These four values are combined by a colon :, to create a single-line entry thats chopped up by the script later.
Trap,Trap#:Device,Device#:Location,Location#:Status,Status#
After being broken up by the script, the data values are injected into a stock event template.
Usage
Using the mibmaker.pl script is very straight forward:
1. Make sure that the input.txt that the script is looking for is present and correct. 2. Run the script, check that the output is ok.
mibmaker.pl | more
3. Run the script again sending the output to an event file.
mibmaker.pl > output.events.xml
4. !!! Your not done yet, two lines need to be added to out.events.xml befoer OpenNMS will pass them. The <events> tag on the first line and </events> tag on the last line of the file.
<events> ... </events>
--Ljohnson






