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));
}
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);
}
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));
}
Aggregations