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;
}
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;
}
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;
}
}
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;
}
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();
}
Aggregations