use of org.opennms.netmgt.config.SyslogdConfigFactory in project opennms by OpenNMS.
the class SyslogdEventdLoadIT method loadSyslogConfiguration.
private void loadSyslogConfiguration(final String configuration) throws IOException {
InputStream stream = null;
try {
stream = ConfigurationTestUtils.getInputStreamForResource(this, configuration);
m_config = new SyslogdConfigFactory(stream);
} finally {
if (stream != null) {
IOUtils.closeQuietly(stream);
}
}
// Update the beans with the new config.
if (m_syslogSinkConsumer != null) {
m_syslogSinkConsumer.setSyslogdConfig(m_config);
m_syslogSinkModule = m_syslogSinkConsumer.getModule();
}
}
use of org.opennms.netmgt.config.SyslogdConfigFactory in project opennms by OpenNMS.
the class SyslogdLoadIT method loadSyslogConfiguration.
private void loadSyslogConfiguration(final String configuration) throws IOException {
InputStream stream = null;
try {
stream = ConfigurationTestUtils.getInputStreamForResource(this, configuration);
m_config = new SyslogdConfigFactory(stream);
} finally {
if (stream != null) {
IOUtils.closeQuietly(stream);
}
}
// Update the beans with the new config.
if (m_syslogSinkConsumer != null) {
m_syslogSinkConsumer.setSyslogdConfig(m_config);
m_syslogSinkModule = m_syslogSinkConsumer.getModule();
}
}
use of org.opennms.netmgt.config.SyslogdConfigFactory in project opennms by OpenNMS.
the class SyslogMessageTest method testCustomParserWithSimpleForwardingRegexAndSyslog21Message.
@Test
public void testCustomParserWithSimpleForwardingRegexAndSyslog21Message() throws Exception {
// see: http://searchdatacenter.techtarget.com/tip/Turn-aggregated-syslog-messages-into-OpenNMS-events
final InputStream stream = new ByteArrayInputStream(("<syslogd-configuration>" + "<configuration " + "syslog-port=\"10514\" " + "new-suspect-on-message=\"false\" " + "forwarding-regexp=\"^((.+?) (.*))\\r?\\n?$\" " + "matching-group-host=\"2\" " + "matching-group-message=\"3\" " + "discard-uei=\"DISCARD-MATCHING-MESSAGES\" " + "/></syslogd-configuration>").getBytes());
final SyslogdConfigFactory config = new SyslogdConfigFactory(stream);
final SyslogParser parser = new CustomSyslogParser(config, SyslogdTestUtils.toByteBuffer("<173>Dec 7 12:02:06 10.13.110.116 mgmtd[8326]: [mgmtd.NOTICE]: Configuration saved to database initial"));
assertTrue(parser.find());
final SyslogMessage message = parser.parse();
final Calendar calendar = new GregorianCalendar();
calendar.set(Calendar.YEAR, ZonedDateTimeBuilder.getBestYearForMonth(Month.DECEMBER.getValue()));
calendar.set(Calendar.MONTH, Calendar.DECEMBER);
calendar.set(Calendar.DATE, 7);
calendar.set(Calendar.HOUR_OF_DAY, 12);
calendar.set(Calendar.MINUTE, 2);
calendar.set(Calendar.SECOND, 6);
calendar.set(Calendar.MILLISECOND, 0);
final Date date = calendar.getTime();
LOG.debug("got message: {}", message);
assertEquals(SyslogFacility.LOCAL5, message.getFacility());
assertEquals(SyslogSeverity.NOTICE, message.getSeverity());
assertEquals(null, message.getMessageID());
assertEquals(date, message.getDate());
assertEquals("10.13.110.116", message.getHostName());
assertEquals("mgmtd", message.getProcessName());
assertEquals("8326", message.getProcessId());
assertEquals("[mgmtd.NOTICE]: Configuration saved to database initial", message.getMessage());
}
use of org.opennms.netmgt.config.SyslogdConfigFactory in project opennms by OpenNMS.
the class SyslogSinkConsumerNewSuspectIT method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging(true, "DEBUG");
// Populate the database but don't sync the InterfaceToNodeCache until we're
// inside each test so that we can test different behaviors
m_databasePopulator.populateDatabase();
m_eventIpcManager.addEventListener(m_anticipator);
// Create a mock SyslogdConfig
SyslogdConfigFactory config = loadSyslogConfiguration("/etc/syslogd-rfc-configuration.xml");
m_syslogSinkConsumer = new SyslogSinkConsumer(new MetricRegistry());
m_syslogSinkConsumer.setDistPollerDao(m_distPollerDao);
m_syslogSinkConsumer.setSyslogdConfig(config);
m_syslogSinkConsumer.setEventForwarder(m_eventIpcManager);
m_syslogSinkModule = m_syslogSinkConsumer.getModule();
}
use of org.opennms.netmgt.config.SyslogdConfigFactory in project opennms by OpenNMS.
the class ConvertToEventTest method testNms5984.
@Test
public void testNms5984() throws IOException {
InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/etc/syslogd-nms5984-configuration.xml");
SyslogdConfig config = new SyslogdConfigFactory(stream);
try {
ConvertToEvent convertToEvent = new ConvertToEvent(DistPollerDao.DEFAULT_DIST_POLLER_ID, MonitoringLocationDao.DEFAULT_MONITORING_LOCATION_ID, InetAddressUtils.ONE_TWENTY_SEVEN, 9999, SyslogdTestUtils.toByteBuffer("<11>Jul 19 15:55:21 otrs-test OTRS-CGI-76[14364]: [Error][Kernel::System::ImportExport::ObjectBackend::CI2CILink::ImportDataSave][Line:468]: CILink: Could not create link between CIs!"), config);
LOG.info("Generated event: {}", convertToEvent.getEvent().toString());
} catch (MessageDiscardedException e) {
LOG.error("Message Parsing failed", e);
fail("Message Parsing failed: " + e.getMessage());
}
}
Aggregations