use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class SyslogdIT method testIPPatternsSyslogNG.
@Test
public void testIPPatternsSyslogNG() throws UnknownHostException {
final EventBuilder expectedEventBldr = new EventBuilder("uei.opennms.org/syslogd/system/Debug", "syslogd");
expectedEventBldr.setInterface(InetAddressUtils.ONE_TWENTY_SEVEN);
expectedEventBldr.setLogDest("logndisplay");
expectedEventBldr.setLogMessage("A SyslogNG style message");
m_eventIpcManager.getEventAnticipator().anticipateEvent(expectedEventBldr.getEvent());
final SyslogClient s = new SyslogClient(null, 10, SyslogClient.LOG_DAEMON, InetAddressUtils.ONE_TWENTY_SEVEN);
s.syslog(SyslogClient.LOG_DEBUG, "2007-01-01 127.0.0.1 A SyslogNG style message");
m_eventIpcManager.getEventAnticipator().verifyAnticipated(10000, 0, 0, 0, 0);
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class SyslogSinkConsumer method sendNewSuspectEvent.
private void sendNewSuspectEvent(String localAddr, String trapInterface, String distPoller) {
EventBuilder bldr = new EventBuilder(EventConstants.NEW_SUSPECT_INTERFACE_EVENT_UEI, "syslogd");
bldr.setInterface(addr(trapInterface));
bldr.setHost(localAddr);
bldr.setDistPoller(distPoller);
eventForwarder.sendNow(bldr.getEvent());
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class Nms4335IT method doMessageTest.
/**
* Send a raw syslog message and expect a given event as a result
*
* @param testPDU The raw syslog message as it would appear on the wire (just the UDP payload)
* @param expectedHost The host from which the event should be resolved as originating
* @param expectedUEI The expected UEI of the resulting event
* @param expectedLogMsg The expected contents of the logmsg for the resulting event
*
* @throws UnknownHostException
* @throws InterruptedException
* @throws ExecutionException
*/
private List<Event> doMessageTest(String testPDU, String expectedHost, String expectedUEI, String expectedLogMsg) throws UnknownHostException, InterruptedException, ExecutionException {
SyslogdTestUtils.startSyslogdGracefully(m_syslogd);
final EventBuilder expectedEventBldr = new EventBuilder(expectedUEI, "syslogd");
expectedEventBldr.setInterface(addr(expectedHost));
expectedEventBldr.setLogDest("logndisplay");
expectedEventBldr.setLogMessage(expectedLogMsg);
m_eventIpcManager.getEventAnticipator().anticipateEvent(expectedEventBldr.getEvent());
final SyslogSinkConsumer syslogSinkConsumer = new SyslogSinkConsumer(new MetricRegistry());
syslogSinkConsumer.setDistPollerDao(m_distPollerDao);
syslogSinkConsumer.setSyslogdConfig(m_config);
syslogSinkConsumer.setEventForwarder(m_eventIpcManager);
final SyslogSinkModule syslogSinkModule = syslogSinkConsumer.getModule();
final SyslogClient sc = new SyslogClient(null, 10, SyslogClient.LOG_DAEMON, addr("127.0.0.1"));
final DatagramPacket pkt = sc.getPacket(SyslogClient.LOG_DEBUG, testPDU);
final SyslogMessageLogDTO messageLog = syslogSinkModule.toMessageLog(new SyslogConnection(pkt, false));
syslogSinkConsumer.handleMessage(messageLog);
m_eventIpcManager.getEventAnticipator().verifyAnticipated(5000, 0, 0, 0, 0);
final Event receivedEvent = m_eventIpcManager.getEventAnticipator().getAnticipatedEventsReceived().get(0);
assertEquals("Log messages do not match", expectedLogMsg, receivedEvent.getLogmsg().getContent());
return m_eventIpcManager.getEventAnticipator().getAnticipatedEventsReceived();
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class SyslogdIT method testRegexFacilitySeverityMatch.
@Test
public void testRegexFacilitySeverityMatch() throws Exception {
MockLogAppender.setupLogging(true, "TRACE");
final String testPDU = "2007-01-01 127.0.0.1 beer - Not just for lunch anymore";
final String testUEI = "uei.opennms.org/tests/syslogd/nonMessageMatch/facilitySeverity";
final String testMsg = "beer - Not just for lunch anymore";
final EventBuilder expectedEventBldr = new EventBuilder(testUEI, "syslogd");
expectedEventBldr.setInterface(InetAddressUtils.ONE_TWENTY_SEVEN);
expectedEventBldr.setLogDest("logndisplay");
expectedEventBldr.setLogMessage(testMsg);
expectedEventBldr.addParam("service", "local1");
expectedEventBldr.addParam("severity", "Warning");
m_eventIpcManager.getEventAnticipator().anticipateEvent(expectedEventBldr.getEvent());
final SyslogClient s = new SyslogClient(null, 10, SyslogClient.LOG_LOCAL1, InetAddressUtils.ONE_TWENTY_SEVEN);
s.syslog(SyslogClient.LOG_WARNING, testPDU);
m_eventIpcManager.getEventAnticipator().verifyAnticipated(5000, 0, 0, 0, 0);
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class SyslogdIT method testRegexUEIWithOnlyUserSpecifiedParameterAssignments.
@Test
public void testRegexUEIWithOnlyUserSpecifiedParameterAssignments() throws InterruptedException, UnknownHostException {
final String testPDU = "2007-01-01 127.0.0.1 tea: Secretly replaced cmiskell's tea with 666 ferrets";
final String testUEI = "uei.opennms.org/tests/syslogd/regexParameterAssignmentTest/userSpecifiedOnly";
final String testMsg = "Secretly replaced cmiskell's tea with 666 ferrets";
final String[] testGroups = { "cmiskell's", "666", "ferrets" };
final EventBuilder expectedEventBldr = new EventBuilder(testUEI, "syslogd");
expectedEventBldr.setInterface(InetAddressUtils.ONE_TWENTY_SEVEN);
expectedEventBldr.setLogDest("logndisplay");
expectedEventBldr.setLogMessage(testMsg);
expectedEventBldr.addParam("whoseBeverage", testGroups[0]);
expectedEventBldr.addParam("count", testGroups[1]);
expectedEventBldr.addParam("replacementItem", testGroups[2]);
m_eventIpcManager.getEventAnticipator().anticipateEvent(expectedEventBldr.getEvent());
final SyslogClient s = new SyslogClient(null, 10, SyslogClient.LOG_DAEMON, InetAddressUtils.ONE_TWENTY_SEVEN);
s.syslog(SyslogClient.LOG_DEBUG, testPDU);
m_eventIpcManager.getEventAnticipator().verifyAnticipated(5000, 0, 0, 0, 0);
}
Aggregations