Search in sources :

Example 1 with ThreshdConfigFactory

use of org.opennms.netmgt.config.ThreshdConfigFactory in project opennms by OpenNMS.

the class LatencyThresholdingSetIT method initFactories.

private void initFactories(String threshd, String thresholds) throws Exception {
    LOG.info("Initialize Threshold Factories");
    ThresholdingConfigFactory.setInstance(new ThresholdingConfigFactory(getClass().getResourceAsStream(thresholds)));
    ThreshdConfigFactory.setInstance(new ThreshdConfigFactory(getClass().getResourceAsStream(threshd), "127.0.0.1", false));
}
Also used : ThreshdConfigFactory(org.opennms.netmgt.config.ThreshdConfigFactory) ThresholdingConfigFactory(org.opennms.netmgt.config.ThresholdingConfigFactory)

Example 2 with ThreshdConfigFactory

use of org.opennms.netmgt.config.ThreshdConfigFactory in project opennms by OpenNMS.

the class ScheduledOutagesRestServiceIT method beforeServletStart.

@Override
protected void beforeServletStart() throws Exception {
    MockLogAppender.setupLogging();
    File etc = new File("target/test-work-dir/etc");
    etc.mkdirs();
    m_onmsHome = etc.getParent();
    System.setProperty("opennms.home", m_onmsHome);
    ConfigurationTestUtils.setRelativeHomeDirectory(m_onmsHome);
    // Setup Scheduled Outages Configuration
    File outagesConfig = new File(etc, "poll-outages.xml");
    FileUtils.writeStringToFile(outagesConfig, "<?xml version=\"1.0\"?>" + "<outages>" + "<outage name='my-junit-test' type='weekly'>" + "<time day='monday' begins='13:30:00' ends='13:30:01'/>" + "<interface address='match-any'/>" + "<node id='18'/><node id='40'/>" + "</outage>" + "</outages>");
    m_pollOutagesConfigManager.setConfigResource(new FileSystemResource(outagesConfig));
    m_pollOutagesConfigManager.afterPropertiesSet();
    // Setup Filter DAO
    m_filterDao = EasyMock.createMock(FilterDao.class);
    EasyMock.expect(m_filterDao.getActiveIPAddressList("IPADDR != '0.0.0.0'")).andReturn(Collections.singletonList(InetAddressUtils.getLocalHostAddress())).anyTimes();
    m_filterDao.flushActiveIpAddressListCache();
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(m_filterDao);
    FilterDaoFactory.setInstance(m_filterDao);
    // Setup Collectd Configuration
    File collectdConfig = new File(etc, "collectd-configuration.xml");
    FileUtils.writeStringToFile(collectdConfig, "<?xml version=\"1.0\"?>" + "<collectd-configuration threads=\"50\">" + "<package name=\"example1\">" + "<filter>IPADDR != '0.0.0.0'</filter>" + "<include-range begin=\"1.1.1.1\" end=\"254.254.254.254\"/>" + "<service name=\"SNMP\" interval=\"300000\" user-defined=\"false\" status=\"on\">" + "<parameter key=\"collection\" value=\"default\"/>" + "</service>" + "</package>" + "<collector service=\"SNMP\" class-name=\"org.opennms.netmgt.collectd.SnmpCollector\"/>" + "</collectd-configuration>");
    CollectdConfigFactory collectdConfigFactory = new CollectdConfigFactory(new FileInputStream(collectdConfig), "localhost", false);
    // Setup Pollerd Configuration
    File pollerdConfig = new File(etc, "poller-configuration.xml");
    FileUtils.writeStringToFile(pollerdConfig, "<?xml version=\"1.0\"?>" + "<poller-configuration threads=\"10\" nextOutageId=\"SELECT nextval(\'outageNxtId\')\" serviceUnresponsiveEnabled=\"false\">" + "<node-outage status=\"on\" pollAllIfNoCriticalServiceDefined=\"true\"></node-outage>" + "<package name=\"example1\">" + "<filter>IPADDR != '0.0.0.0'</filter>" + "<rrd step = \"300\">" + "<rra>RRA:AVERAGE:0.5:1:2016</rra>" + "<rra>RRA:AVERAGE:0.5:12:4464</rra>" + "<rra>RRA:MIN:0.5:12:4464</rra>" + "<rra>RRA:MAX:0.5:12:4464</rra>" + "</rrd>" + "<service name=\"ICMP\" interval=\"300000\"/>" + "<downtime begin=\"0\" end=\"30000\"/>" + "</package>" + "<monitor service=\"ICMP\" class-name=\"org.opennms.netmgt.mock.MockMonitor\"/>" + "</poller-configuration>");
    PollerConfigFactory.setInstance(new PollerConfigFactory(1, new FileInputStream(pollerdConfig), "localserver", false));
    // Setup Threshd Configuration
    File threshdConfig = new File(etc, "threshd-configuration.xml");
    FileUtils.writeStringToFile(threshdConfig, "<?xml version=\"1.0\"?>" + "<threshd-configuration threads=\"5\">" + "<package name=\"example1\">" + "<filter>IPADDR != '0.0.0.0'</filter>" + "<include-range begin=\"1.1.1.1\" end=\"254.254.254.254\"/>" + "<service name=\"SNMP\" interval=\"300000\" user-defined=\"false\" status=\"on\">" + "<parameter key=\"thresholding-group\" value=\"mib2\"/>" + "</service>" + "</package>" + "</threshd-configuration>");
    ThreshdConfigFactory.setInstance(new ThreshdConfigFactory(new FileInputStream(threshdConfig), "localserver", false));
    // Setup Notifid Configuration
    FileUtils.writeStringToFile(new File(etc, "notifd-configuration.xml"), "<?xml version=\"1.0\"?>" + "<notifd-configuration status=\"off\" match-all=\"true\">" + "<queue><queue-id>default</queue-id><interval>20s</interval>" + "<handler-class><name>org.opennms.netmgt.notifd.DefaultQueueHandler</name></handler-class>" + "</queue>" + "</notifd-configuration>");
    NotifdConfigFactory.init();
    m_jaxbContext = JaxbUtils.getContextFor(Outages.class);
}
Also used : ThreshdConfigFactory(org.opennms.netmgt.config.ThreshdConfigFactory) Outages(org.opennms.netmgt.config.poller.outages.Outages) FilterDao(org.opennms.netmgt.filter.api.FilterDao) PollerConfigFactory(org.opennms.netmgt.config.PollerConfigFactory) CollectdConfigFactory(org.opennms.netmgt.config.CollectdConfigFactory) FileSystemResource(org.springframework.core.io.FileSystemResource) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with ThreshdConfigFactory

use of org.opennms.netmgt.config.ThreshdConfigFactory in project opennms by OpenNMS.

the class ThresholdingVisitorIT method initFactories.

private void initFactories(String threshd, String thresholds) throws Exception {
    LOG.info("Initialize Threshold Factories");
    ThresholdingConfigFactory.setInstance(new ThresholdingConfigFactory(getClass().getResourceAsStream(thresholds)));
    ThreshdConfigFactory.setInstance(new ThreshdConfigFactory(getClass().getResourceAsStream(threshd), "127.0.0.1", false));
}
Also used : ThreshdConfigFactory(org.opennms.netmgt.config.ThreshdConfigFactory) ThresholdingConfigFactory(org.opennms.netmgt.config.ThresholdingConfigFactory)

Aggregations

ThreshdConfigFactory (org.opennms.netmgt.config.ThreshdConfigFactory)3 ThresholdingConfigFactory (org.opennms.netmgt.config.ThresholdingConfigFactory)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 CollectdConfigFactory (org.opennms.netmgt.config.CollectdConfigFactory)1 PollerConfigFactory (org.opennms.netmgt.config.PollerConfigFactory)1 Outages (org.opennms.netmgt.config.poller.outages.Outages)1 FilterDao (org.opennms.netmgt.filter.api.FilterDao)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1