Search in sources :

Example 1 with Logmsg

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

the class SpectrumTrapImporter method makeLogMsg.

public Logmsg makeLogMsg(AlertMapping mapping, EventDisposition dispo) {
    Logmsg msg = new Logmsg();
    if (!dispo.isPersistent()) {
        msg.setDest("donotpersist");
    } else if (!dispo.isLogEvent()) {
        msg.setDest("discardtraps");
    } else {
        msg.setDest("logndisplay");
    }
    msg.setContent("<p>" + makeEventLabel(mapping) + "</p>");
    return msg;
}
Also used : Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg)

Example 2 with Logmsg

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

the class EventconfFactorySaveTest method getAddableEvent.

private static Event getAddableEvent() {
    Event event = new Event();
    event.setUei(newUEI);
    event.setEventLabel(newEventLabel);
    event.setDescr(newDescr);
    Logmsg logmsg = new Logmsg();
    logmsg.setDest(newDest);
    logmsg.setContent(newContent);
    event.setLogmsg(logmsg);
    event.setSeverity(newSeverity);
    return event;
}
Also used : Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg) Event(org.opennms.netmgt.xml.eventconf.Event)

Example 3 with Logmsg

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

the class ThresholdController method ensureUEIInEventConf.

private void ensureUEIInEventConf(org.opennms.netmgt.xml.eventconf.Event source, String targetUei, ThresholdType thresholdType, String clearKey, boolean isTrigger) {
    List<org.opennms.netmgt.xml.eventconf.Event> eventsForUEI = m_eventConfDao.getEvents(targetUei);
    if (eventsForUEI == null || eventsForUEI.size() == 0) {
        String typeDesc = isTrigger ? "exceeded" : "rearmed";
        org.opennms.netmgt.xml.eventconf.Event event = new org.opennms.netmgt.xml.eventconf.Event();
        event.setUei(targetUei);
        event.setEventLabel("User-defined " + thresholdType + " threshold event " + typeDesc + ": " + targetUei);
        Logmsg logmsg = new Logmsg();
        event.setLogmsg(logmsg);
        if (source == null) {
            event.setDescr("Threshold " + typeDesc + " for %service% datasource %parm[ds]% on interface %interface%, parms: %parm[all]%");
            logmsg.setDest(LogDestType.LOGNDISPLAY);
            logmsg.setContent("Threshold " + typeDesc + " for %service% datasource %parm[ds]% on interface %interface%, parms: %parm[all]%");
            event.setLogmsg(logmsg);
            event.setSeverity("Warning");
        } else {
            event.setDescr(source.getDescr());
            event.setSeverity(source.getSeverity());
            event.setOperinstruct(source.getOperinstruct());
            logmsg.setDest(source.getLogmsg().getDest());
            logmsg.setContent(source.getLogmsg().getContent());
            if (source.getAlarmData() != null) {
                final AlarmData alarmData = new AlarmData();
                final AlarmData sourceAlarmData = source.getAlarmData();
                alarmData.setAlarmType(sourceAlarmData.getAlarmType());
                alarmData.setAutoClean(sourceAlarmData.getAutoClean());
                alarmData.setReductionKey(sourceAlarmData.getReductionKey());
                if (!isTrigger && clearKey != null) {
                    alarmData.setClearKey(clearKey);
                }
                event.setAlarmData(alarmData);
            }
        }
        m_eventConfDao.addEventToProgrammaticStore(event);
        eventConfChanged = true;
    }
}
Also used : Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg) Event(org.opennms.netmgt.xml.event.Event) AlarmData(org.opennms.netmgt.xml.eventconf.AlarmData)

Example 4 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 5 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