Search in sources :

Example 6 with Maskelement

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);
}
Also used : Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement)

Example 7 with Maskelement

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;
}
Also used : Mask(org.opennms.netmgt.xml.eventconf.Mask) Event(org.opennms.netmgt.xml.eventconf.Event) Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement)

Example 8 with Maskelement

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.");
    }
}
Also used : Events(org.opennms.netmgt.xml.eventconf.Events) Varbindsdecode(org.opennms.netmgt.xml.eventconf.Varbindsdecode) Event(org.opennms.netmgt.xml.eventconf.Event) Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement) File(java.io.File) Test(org.junit.Test)

Example 9 with Maskelement

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");
    }
}
Also used : Events(org.opennms.netmgt.xml.eventconf.Events) Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement) File(java.io.File) Test(org.junit.Test)

Aggregations

Maskelement (org.opennms.netmgt.xml.eventconf.Maskelement)9 File (java.io.File)3 Test (org.junit.Test)3 Event (org.opennms.netmgt.xml.eventconf.Event)3 Events (org.opennms.netmgt.xml.eventconf.Events)3 Mask (org.opennms.netmgt.xml.eventconf.Mask)2 Varbindsdecode (org.opennms.netmgt.xml.eventconf.Varbindsdecode)2