Search in sources :

Example 1 with Maskelement

use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.

the class SpectrumTrapImporter method makeEventMask.

public Mask makeEventMask(AlertMapping mapping) {
    Mask mask = new Mask();
    // Trap-OID
    Maskelement me = new Maskelement();
    me.setMename("id");
    me.setMevalue(new String[] { mapping.getTrapOid() });
    mask.addMaskelement(me);
    // Generic-type
    me = new Maskelement();
    me.setMename("generic");
    me.setMevalue(new String[] { mapping.getTrapGenericType() });
    mask.addMaskelement(me);
    // Specific-type
    me = new Maskelement();
    me.setMename("specific");
    me.setMevalue(new String[] { mapping.getTrapSpecificType() });
    mask.addMaskelement(me);
    return mask;
}
Also used : Mask(org.opennms.netmgt.xml.eventconf.Mask) Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement)

Example 2 with Maskelement

use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.

the class Mib2Events method addMaskElement.

private void addMaskElement(Event event, String name, String value) {
    if (event.getMask() == null) {
        throw new IllegalStateException("Event mask is null, must have been set before this method was called");
    }
    Maskelement me = new Maskelement();
    me.setMename(name);
    me.addMevalue(value);
    event.getMask().addMaskelement(me);
}
Also used : Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement)

Example 3 with Maskelement

use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.

the class EventExpander method transform.

/**
 * This method is used to transform an event configuration mask instance
 * into an event mask instance. This is used when the incoming event does
 * not have a mask and the information from the configuration object is
 * copied.
 *
 * @param src
 *            The configuration source to transform.
 *
 * @return The transformed mask information.
 */
private org.opennms.netmgt.xml.event.Mask transform(org.opennms.netmgt.xml.eventconf.Mask src) {
    org.opennms.netmgt.xml.event.Mask dest = new org.opennms.netmgt.xml.event.Mask();
    for (final Maskelement confme : src.getMaskelements()) {
        // create new mask element
        org.opennms.netmgt.xml.event.Maskelement me = new org.opennms.netmgt.xml.event.Maskelement();
        // set name
        me.setMename(confme.getMename());
        me.setMevalueCollection(confme.getMevalues());
        dest.addMaskelement(me);
    }
    return dest;
}
Also used : Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement)

Example 4 with Maskelement

use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.

the class JsmiMibParser method addMaskElement.

/**
 * Adds the mask element.
 *
 * @param event the event object
 * @param name the name
 * @param value the value
 */
private void addMaskElement(Event event, String name, String value) {
    if (event.getMask() == null) {
        throw new IllegalStateException("Event mask is not present, must have been set before this method was called");
    }
    Maskelement me = new Maskelement();
    me.setMename(name);
    me.addMevalue(value);
    event.getMask().addMaskelement(me);
}
Also used : Maskelement(org.opennms.netmgt.xml.eventconf.Maskelement)

Example 5 with Maskelement

use of org.opennms.netmgt.xml.eventconf.Maskelement in project opennms by OpenNMS.

the class JsmiMibParserTest method testNotifications.

/**
 * Test generate events from notifications.
 *
 * @throws Exception the exception
 */
@Test
public void testNotifications() throws Exception {
    if (parser.parseMib(new File(MIB_DIR, "IF-MIB.txt"))) {
        Events events = parser.getEvents("uei.opennms.org/traps/ifmib");
        Assert.assertNotNull(events);
        System.out.println(JaxbUtils.marshal(events));
        Assert.assertEquals(2, events.getEvents().size());
        Event event = null;
        for (Event e : events.getEvents()) {
            if (e.getUei().contains("linkDown"))
                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("IF-MIB defined trap event: linkDown", event.getEventLabel());
        Assert.assertNotNull(event.getMask());
        for (final Maskelement me : event.getMask().getMaskelements()) {
            if (me.getMename().equals("id"))
                Assert.assertEquals(".1.3.6.1.6.3.1.1.5", me.getMevalues().get(0));
            if (me.getMename().equals("generic"))
                Assert.assertEquals("6", me.getMevalues().get(0));
            if (me.getMename().equals("specific"))
                Assert.assertEquals("3", me.getMevalues().get(0));
        }
        Assert.assertEquals(2, event.getVarbindsdecodes().size());
        for (Varbindsdecode vb : event.getVarbindsdecodes()) {
            if (vb.getParmid().equals("parm[#2]"))
                Assert.assertEquals(3, vb.getDecodes().size());
            if (vb.getParmid().equals("parm[#3]"))
                Assert.assertEquals(7, vb.getDecodes().size());
        }
    } else {
        Assert.fail("The IF-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)

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