use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class TransactionAwareEventForwarder method sendNow.
/** {@inheritDoc} */
@Override
public void sendNow(Event event) {
Log eventLog = new Log();
Events events = new Events();
eventLog.setEvents(events);
events.addEvent(event);
sendNow(eventLog);
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class EventTranslator method onEvent.
/** {@inheritDoc} */
@Override
public void onEvent(Event e) {
if (isReloadConfigEvent(e)) {
handleReloadEvent(e);
return;
}
if (getName().equals(e.getSource())) {
LOG.debug("onEvent: ignoring event with EventTranslator as source");
return;
}
if (!m_config.isTranslationEvent(e)) {
LOG.debug("onEvent: received event that matches no translations: \n", EventUtils.toString(e));
return;
}
LOG.debug("onEvent: received valid registered translation event: \n", EventUtils.toString(e));
List<Event> translated = m_config.translateEvent(e);
if (translated != null) {
Log log = new Log();
Events events = new Events();
for (Iterator<Event> iter = translated.iterator(); iter.hasNext(); ) {
Event event = iter.next();
events.addEvent(event);
LOG.debug("onEvent: sended translated event: \n", EventUtils.toString(event));
}
log.setEvents(events);
getEventManager().sendNow(log);
}
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class ThresholdingEventProxy method sendAllEvents.
/**
* <p>sendAllEvents</p>
*/
public void sendAllEvents() {
if (m_events.size() > 0) {
try {
Log log = new Log();
Events events = new Events();
for (Event e : m_events) {
events.addEvent(e);
}
log.setEvents(events);
EventIpcManagerFactory.getIpcManager().sendNow(log);
} catch (Throwable e) {
LOG.info("sendAllEvents: Failed sending threshold events", e);
}
removeAllEvents();
}
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class TrapSinkConsumer method handleMessage.
@Override
public void handleMessage(TrapLogDTO messageLog) {
try (Logging.MDCCloseable mdc = Logging.withPrefixCloseable(Trapd.LOG4J_CATEGORY)) {
final Log eventLog = toLog(messageLog);
eventForwarder.sendNowSync(eventLog);
// If configured, also send events for new suspects
if (config.getNewSuspectOnTrap()) {
eventLog.getEvents().getEventCollection().stream().filter(e -> !e.hasNodeid()).forEach(e -> {
sendNewSuspectEvent(e.getInterface(), e.getDistPoller());
LOG.debug("Sent newSuspectEvent for interface {}", e.getInterface());
});
}
}
}
use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.
the class SyslogdEventdLoadIT method testEventd.
@Test(timeout = 120000)
@Transactional
public void testEventd() throws Exception {
m_eventd.start();
EventProxy ep = createEventProxy();
Log eventLog = new Log();
Events events = new Events();
eventLog.setEvents(events);
int eventCount = 10000;
m_eventCounter.setAnticipated(eventCount);
for (int i = 0; i < eventCount; i++) {
int eventNum = Double.valueOf(Math.random() * 300).intValue();
String expectedUei = "uei.example.org/syslog/loadTest/foo" + eventNum;
final EventBuilder eb = new EventBuilder(expectedUei, "SyslogdLoadTest");
Event thisEvent = eb.setInterface(addr("127.0.0.1")).setLogDest("logndisplay").setLogMessage("A load test has been received as a Syslog Message").getEvent();
// LOG.debug("event = {}", thisEvent);
events.addEvent(thisEvent);
}
long start = System.currentTimeMillis();
ep.send(eventLog);
long mid = System.currentTimeMillis();
// wait up to 2 minutes for the events to come through
m_eventCounter.waitForFinish(120000);
long end = System.currentTimeMillis();
m_eventd.stop();
final long total = (end - start);
final double eventsPerSecond = (eventCount * 1000.0 / total);
System.err.println(String.format("total time: %d, wait time: %d, events per second: %8.4f", total, (end - mid), eventsPerSecond));
}
Aggregations