Search in sources :

Example 1 with ProcessMatch

use of org.opennms.netmgt.config.syslogd.ProcessMatch in project opennms by OpenNMS.

the class SyslogdIT method setUp.

@Before
public void setUp() throws Exception {
    MockLogAppender.setupLogging();
    MockLogAppender.resetState();
    InputStream stream = null;
    try {
        stream = ConfigurationTestUtils.getInputStreamForResource(this, "/etc/syslogd-configuration.xml");
        m_config = new SyslogdConfigFactory(stream);
    } finally {
        if (stream != null) {
            IOUtils.closeQuietly(stream);
        }
    }
    // Verify that the test syslogd-configuration.xml file was loaded
    boolean foundBeer = false;
    boolean foundMalt = false;
    assertEquals(10514, m_config.getSyslogPort());
    for (final UeiMatch match : m_config.getUeiList()) {
        if (match.getProcessMatch().isPresent()) {
            final ProcessMatch processMatch = match.getProcessMatch().get();
            if (!foundBeer && "beerd".equals(processMatch.getExpression())) {
                foundBeer = true;
            } else if (!foundMalt && "maltd".equals(processMatch.getExpression())) {
                foundMalt = true;
            }
        }
    }
    assertTrue(foundBeer);
    assertTrue(foundMalt);
    m_syslogSinkConsumer = new SyslogSinkConsumer(new MetricRegistry());
    m_syslogSinkConsumer.setDistPollerDao(m_distPollerDao);
    m_syslogSinkConsumer.setSyslogdConfig(m_config);
    m_syslogSinkConsumer.setEventForwarder(m_eventIpcManager);
    m_syslogSinkModule = m_syslogSinkConsumer.getModule();
    m_messageDispatcherFactory.setConsumer(m_syslogSinkConsumer);
    SyslogReceiverJavaNetImpl receiver = new SyslogReceiverJavaNetImpl(m_config);
    receiver.setDistPollerDao(m_distPollerDao);
    receiver.setMessageDispatcherFactory(m_messageDispatcherFactory);
    m_syslogd.setSyslogReceiver(receiver);
    m_syslogd.init();
    SyslogdTestUtils.startSyslogdGracefully(m_syslogd);
}
Also used : ProcessMatch(org.opennms.netmgt.config.syslogd.ProcessMatch) InputStream(java.io.InputStream) MetricRegistry(com.codahale.metrics.MetricRegistry) UeiMatch(org.opennms.netmgt.config.syslogd.UeiMatch) SyslogdConfigFactory(org.opennms.netmgt.config.SyslogdConfigFactory) Before(org.junit.Before)

Aggregations

MetricRegistry (com.codahale.metrics.MetricRegistry)1 InputStream (java.io.InputStream)1 Before (org.junit.Before)1 SyslogdConfigFactory (org.opennms.netmgt.config.SyslogdConfigFactory)1 ProcessMatch (org.opennms.netmgt.config.syslogd.ProcessMatch)1 UeiMatch (org.opennms.netmgt.config.syslogd.UeiMatch)1