Search in sources :

Example 6 with Logmsg

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

the class Mib2Events method getTrapEventLogmsg.

public Logmsg getTrapEventLogmsg(MibValueSymbol trapValueSymbol) {
    Logmsg msg = new Logmsg();
    msg.setDest("logndisplay");
    final StringBuffer dbuf = new StringBuffer();
    dbuf.append("<p>");
    dbuf.append("\n");
    dbuf.append("\t").append(trapValueSymbol.getName()).append(" trap received\n");
    int vbNum = 1;
    for (MibValue vb : getTrapVars(trapValueSymbol)) {
        dbuf.append("\t").append(vb.getName()).append("=%parm[#").append(vbNum).append("]%\n");
        vbNum++;
    }
    if (dbuf.charAt(dbuf.length() - 1) == '\n') {
        // delete the \n at the end
        dbuf.deleteCharAt(dbuf.length() - 1);
    }
    dbuf.append("</p>\n\t");
    msg.setContent(dbuf.toString());
    return msg;
}
Also used : Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg) MibValue(net.percederberg.mibble.MibValue)

Example 7 with Logmsg

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

the class EventConfDataTest method anticipateAndSend.

public void anticipateAndSend(String event, Event snmp) {
    /*
		if (event != null) {
			createEvent(event);
		}
         */
    org.opennms.netmgt.xml.eventconf.Event econf = eventConfDao.findByEvent(snmp);
    System.out.println("Eventconf: " + (econf == null ? null : new EventConfWrapper(econf)));
    if (event != null) {
        if (econf == null) {
            fail("Was expecting to match an eventconf with a UEI of \"" + event + "\", but no matching eventconf was found.");
        } else {
            if (!event.equals(econf.getUei())) {
                fail("Was expecting to match an eventconf with a UEI of \"" + event + "\", but received an eventconf with a UEI of \"" + econf.getUei() + "\"");
            }
        // everything's fine
        }
    } else {
        if (econf != null) {
            boolean complain = true;
            Logmsg logmsg = econf.getLogmsg();
            if (logmsg != null) {
                LogDestType dest = logmsg.getDest();
                if (LogDestType.DISCARDTRAPS.equals(dest)) {
                    complain = false;
                }
            }
            if (complain) {
                fail("Was not expecting an eventconf, but received an eventconf with " + "an UEI of \"" + econf.getUei() + "\"");
            }
        }
    // everything's fine
    }
    finishUp();
}
Also used : Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg) LogDestType(org.opennms.netmgt.xml.eventconf.LogDestType)

Aggregations

Logmsg (org.opennms.netmgt.xml.eventconf.Logmsg)7 MibValue (net.percederberg.mibble.MibValue)1 SmiVariable (org.jsmiparser.smi.SmiVariable)1 Event (org.opennms.netmgt.xml.event.Event)1 AlarmData (org.opennms.netmgt.xml.eventconf.AlarmData)1 Event (org.opennms.netmgt.xml.eventconf.Event)1 LogDestType (org.opennms.netmgt.xml.eventconf.LogDestType)1 Mask (org.opennms.netmgt.xml.eventconf.Mask)1