use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.
the class MaskElementField method addHandler.
/**
* Adds the handler.
*/
private void addHandler() {
Maskelement e = new Maskelement();
e.setMename("??");
container.addOnmsBean(e);
}
use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.
the class OidMapping method makeEvent.
public Event makeEvent() {
Event evt = new Event();
Mask mask = new Mask();
// Trap-OID
Maskelement me = new Maskelement();
me.setMename("id");
evt.setMask(mask);
return evt;
}
use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.
the class JsmiMibParserTest method testTraps.
/**
* Test generate events from traps.
*/
@Test
public void testTraps() {
if (parser.parseMib(new File(MIB_DIR, "RFC1269-MIB.txt"))) {
Assert.assertEquals("RFC1269-MIB", parser.getMibName());
Events events = parser.getEvents("uei.opennms.org/traps/RFC1269");
Assert.assertNotNull(events);
Assert.assertEquals(2, events.getEvents().size());
System.out.println(JaxbUtils.marshal(events));
Assert.assertEquals(2, events.getEvents().size());
Event event = null;
for (Event e : events.getEvents()) {
if (e.getUei().contains("bgpBackwardTransition"))
event = e;
}
Assert.assertNotNull(event);
// TODO Must be more specific
Assert.assertNotNull(event.getDescr());
Assert.assertNotNull(event.getLogmsg());
// TODO Must be more specific
Assert.assertNotNull(event.getLogmsg().getContent());
Assert.assertEquals("Indeterminate", event.getSeverity());
Assert.assertEquals("RFC1269-MIB defined trap event: bgpBackwardTransition", event.getEventLabel());
Assert.assertNotNull(event.getMask());
for (final Maskelement me : event.getMask().getMaskelements()) {
if (me.getMename().equals("id"))
Assert.assertEquals(".1.3.6.1.2.1.15", me.getMevalues().get(0));
if (me.getMename().equals("generic"))
Assert.assertEquals("6", me.getMevalues().get(0));
if (me.getMename().equals("specific"))
Assert.assertEquals("2", me.getMevalues().get(0));
}
Assert.assertEquals(1, event.getVarbindsdecodes().size());
for (Varbindsdecode vb : event.getVarbindsdecodes()) {
if (vb.getParmid().equals("parm[#3]"))
Assert.assertEquals(6, vb.getDecodes().size());
}
} else {
Assert.fail("The RFC1269-MIB.txt file couldn't be parsed successfully.");
}
}
use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.
the class SPC592Test method testIsisMibTrapOids.
/**
* Test trap-OIDs in events from ISIS-MIB notifications.
*
* @throws Exception the exception
*/
@Test
public void testIsisMibTrapOids() throws Exception {
if (!parser.parseMib(new File(MIB_DIR, "ISIS-MIB.mib"))) {
Assert.fail("The ISIS-MIB.mib must parse successfully");
} else {
Assert.assertTrue(parser.getMissingDependencies().isEmpty());
}
Events isisEvents = parser.getEvents("uei.opennms.org/issues/SPC592/");
assertEquals(isisEvents.getEvents().size(), 18);
assertEquals("uei.opennms.org/issues/SPC592/isisAdjacencyChange", isisEvents.getEvents().get(16).getUei());
boolean foundId = false;
for (final Maskelement me : isisEvents.getEvents().get(16).getMask().getMaskelements()) {
if ("id".equals(me.getMename())) {
foundId = true;
}
if (foundId) {
assertEquals("Only one me-value should be present for trap OID", 1, me.getMevalues().size());
assertFalse("The 'id' mask-element value for the isisAdjacencyChange event must not end in .0", me.getMevalues().get(0).endsWith(".0"));
assertEquals("The 'id' mask-element value for the isisAdjacencyChange event is incorrect", me.getMevalues().get(0), ".1.3.6.1.2.1.138");
break;
}
}
if (!foundId) {
Assert.fail("Never found the 'id' mask-element in the isisAdjacencyChange event");
}
boolean foundSpecific = false;
for (final Maskelement me : isisEvents.getEvents().get(16).getMask().getMaskelements()) {
if ("specific".equals(me.getMename())) {
foundSpecific = true;
}
if (foundSpecific) {
assertEquals("Only one me-value should be present for the specific-type", 1, me.getMevalues().size());
assertEquals("The 'specific' mask-element value for the isisAdjacencyChange event must be 17", me.getMevalues().get(0), "17");
}
}
if (!foundSpecific) {
Assert.fail("Never found the 'specific' mask-element in the isisAdjacencyChange event");
}
}
Aggregations