Search in sources :

Example 6 with Events

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);
}
Also used : Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events)

Example 7 with Events

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);
    }
}
Also used : Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events) Event(org.opennms.netmgt.xml.event.Event)

Example 8 with Events

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();
    }
}
Also used : Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events) Event(org.opennms.netmgt.xml.event.Event)

Example 9 with Events

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());
            });
        }
    }
}
Also used : Logging(org.opennms.core.logging.Logging) SinkModule(org.opennms.core.ipc.sink.api.SinkModule) TrapdInstrumentation(org.opennms.netmgt.trapd.jmx.TrapdInstrumentation) LogDestType(org.opennms.netmgt.xml.eventconf.LogDestType) Logger(org.slf4j.Logger) InetAddressUtils(org.opennms.core.utils.InetAddressUtils) Logging(org.opennms.core.logging.Logging) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) InterfaceToNodeCache(org.opennms.netmgt.dao.api.InterfaceToNodeCache) EventBuilder(org.opennms.netmgt.model.events.EventBuilder) InetAddressUtils.addr(org.opennms.core.utils.InetAddressUtils.addr) MessageConsumerManager(org.opennms.core.ipc.sink.api.MessageConsumerManager) TrapdConfig(org.opennms.netmgt.config.TrapdConfig) Events(org.opennms.netmgt.xml.event.Events) DistPollerDao(org.opennms.netmgt.dao.api.DistPollerDao) Event(org.opennms.netmgt.xml.event.Event) Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg) PostConstruct(javax.annotation.PostConstruct) EventForwarder(org.opennms.netmgt.events.api.EventForwarder) Qualifier(org.springframework.beans.factory.annotation.Qualifier) MessageConsumer(org.opennms.core.ipc.sink.api.MessageConsumer) EventConfDao(org.opennms.netmgt.config.api.EventConfDao) Log(org.opennms.netmgt.xml.event.Log) Log(org.opennms.netmgt.xml.event.Log)

Example 10 with Events

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));
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events) Event(org.opennms.netmgt.xml.event.Event) TcpEventProxy(org.opennms.netmgt.events.api.support.TcpEventProxy) EventProxy(org.opennms.netmgt.events.api.EventProxy) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Events (org.opennms.netmgt.xml.event.Events)14 Log (org.opennms.netmgt.xml.event.Log)14 Event (org.opennms.netmgt.xml.event.Event)9 Test (org.junit.Test)4 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)4 EventProxy (org.opennms.netmgt.events.api.EventProxy)2 TcpEventProxy (org.opennms.netmgt.events.api.support.TcpEventProxy)2 Transactional (org.springframework.transaction.annotation.Transactional)2 PostConstruct (javax.annotation.PostConstruct)1 MessageConsumer (org.opennms.core.ipc.sink.api.MessageConsumer)1 MessageConsumerManager (org.opennms.core.ipc.sink.api.MessageConsumerManager)1 SinkModule (org.opennms.core.ipc.sink.api.SinkModule)1 Logging (org.opennms.core.logging.Logging)1 InetAddressUtils (org.opennms.core.utils.InetAddressUtils)1 InetAddressUtils.addr (org.opennms.core.utils.InetAddressUtils.addr)1 TrapdConfig (org.opennms.netmgt.config.TrapdConfig)1 EventConfDao (org.opennms.netmgt.config.api.EventConfDao)1 DistPollerDao (org.opennms.netmgt.dao.api.DistPollerDao)1 InterfaceToNodeCache (org.opennms.netmgt.dao.api.InterfaceToNodeCache)1 EventForwarder (org.opennms.netmgt.events.api.EventForwarder)1