Search in sources :

Example 1 with Events

use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.

the class TrapSinkConsumer method toLog.

private Log toLog(TrapLogDTO messageLog) {
    final Log log = new Log();
    final Events events = new Events();
    log.setEvents(events);
    for (TrapDTO eachMessage : messageLog.getMessages()) {
        try {
            final Event event = eventCreator.createEventFrom(eachMessage, messageLog.getSystemId(), messageLog.getLocation(), messageLog.getTrapAddress());
            if (!shouldDiscard(event)) {
                if (event.getSnmp() != null) {
                    trapdInstrumentation.incTrapsReceivedCount(event.getSnmp().getVersion());
                }
                events.addEvent(event);
            } else {
                LOG.debug("Trap discarded due to matching event having logmsg dest == discardtraps");
                trapdInstrumentation.incDiscardCount();
            }
        } catch (Throwable e) {
            LOG.error("Unexpected error processing trap: {}", eachMessage, e);
            trapdInstrumentation.incErrorCount();
        }
    }
    return 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 2 with Events

use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.

the class JaxbUtilsTest method testMarshalLog.

@Test
public void testMarshalLog() throws Exception {
    final Event e1 = getEvent();
    final Event e2 = getEvent();
    e2.setDescr("test 2");
    final Events events = new Events();
    events.addEvent(e1);
    events.addEvent(e2);
    final Log log = new Log();
    log.setEvents(events);
    final String xml = JaxbUtils.marshal(log);
    LOG.debug("xml = {}", xml);
    assertNotNull(xml);
    assertTrue(xml.contains("JaxbUtilsTest"));
}
Also used : Events(org.opennms.netmgt.xml.event.Events) Log(org.opennms.netmgt.xml.event.Log) Event(org.opennms.netmgt.xml.event.Event) Test(org.junit.Test)

Example 3 with Events

use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.

the class EventIpcManagerDefaultImpl method sendNowSync.

@Override
public void sendNowSync(Event event) {
    Objects.requireNonNull(event);
    Events events = new Events();
    events.addEvent(event);
    Log eventLog = new Log();
    eventLog.setEvents(events);
    sendNowSync(eventLog);
}
Also used : Events(org.opennms.netmgt.xml.event.Events) Log(org.opennms.netmgt.xml.event.Log)

Example 4 with Events

use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.

the class SyslogSinkConsumer method toEventLog.

public Log toEventLog(SyslogMessageLogDTO messageLog) {
    final Log elog = new Log();
    final Events events = new Events();
    elog.setEvents(events);
    for (SyslogMessageDTO message : messageLog.getMessages()) {
        try {
            LOG.debug("Converting syslog message into event.");
            ConvertToEvent re = new ConvertToEvent(messageLog.getSystemId(), messageLog.getLocation(), messageLog.getSourceAddress(), messageLog.getSourcePort(), message.getBytes(), syslogdConfig);
            events.addEvent(re.getEvent());
        } catch (final MessageDiscardedException e) {
            LOG.info("Message discarded, returning without enqueueing event.", e);
        } catch (final Throwable e) {
            LOG.error("Unexpected exception while processing SyslogConnection", e);
        }
    }
    return elog;
}
Also used : SyslogMessageDTO(org.opennms.netmgt.syslogd.api.SyslogMessageDTO) Log(org.opennms.netmgt.xml.event.Log) Events(org.opennms.netmgt.xml.event.Events)

Example 5 with Events

use of org.opennms.netmgt.xml.event.Events in project opennms by OpenNMS.

the class EventIpcManagerDefaultImpl method sendNow.

/**
 * {@inheritDoc}
 *
 * Called by a service to send an event to other listeners.
 */
@Override
public void sendNow(Event event) {
    Assert.notNull(event, "event argument cannot be null");
    Events events = new Events();
    events.addEvent(event);
    Log eventLog = new Log();
    eventLog.setEvents(events);
    sendNow(eventLog);
}
Also used : Events(org.opennms.netmgt.xml.event.Events) Log(org.opennms.netmgt.xml.event.Log)

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