use of org.opennms.netmgt.config.CollectdConfigFactory in project opennms by OpenNMS.
the class DefaultResourceDaoTest method setUpCollectdConfigFactory.
private void setUpCollectdConfigFactory() throws IOException {
InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/collectdconfiguration-testdata.xml");
m_collectdConfig = new CollectdConfigFactory(stream, "localhost", false);
stream.close();
}
use of org.opennms.netmgt.config.CollectdConfigFactory 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.CollectdConfigFactory in project opennms by OpenNMS.
the class CollectorConfigDaoImplIT method initialize.
private void initialize() throws IOException, Exception {
System.setProperty("opennms.home", ConfigurationTestUtils.getDaemonEtcDirectory().getParentFile().getAbsolutePath());
InputStream stream = null;
stream = getInputStreamForFile("/org/opennms/netmgt/config/test-database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(stream));
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/snmp-config.xml");
SnmpPeerFactory.setInstance(new SnmpPeerFactory(new InputStreamResource(stream)));
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/datacollection-config.xml");
DefaultDataCollectionConfigDao dataCollectionDao = new DefaultDataCollectionConfigDao();
dataCollectionDao.setConfigResource(new InputStreamResource(stream));
dataCollectionDao.afterPropertiesSet();
DataCollectionConfigFactory.setInstance(dataCollectionDao);
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/collectd-testdata.xml");
try {
new CollectdConfigFactory(stream, "localhost", false);
} finally {
stream.close();
}
}
use of org.opennms.netmgt.config.CollectdConfigFactory in project opennms by OpenNMS.
the class FindTopLevelResourcesTest method setUp.
@Before
public void setUp() throws Exception {
m_fileAnticipator = new FileAnticipator();
m_easyMockUtils = new EasyMockUtils();
m_nodeDao = m_easyMockUtils.createMock(NodeDao.class);
m_locationMonitorDao = m_easyMockUtils.createMock(LocationMonitorDao.class);
m_resourceTypesDao = m_easyMockUtils.createMock(ResourceTypesDao.class);
m_filterDao = m_easyMockUtils.createMock(FilterDao.class);
FilterDaoFactory.setInstance(m_filterDao);
expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
RrdStrategy<?, ?> rrdStrategy = new JRobinRrdStrategy();
m_rrdFileExtension = rrdStrategy.getDefaultFileExtension();
m_resourceStorageDao.setRrdDirectory(m_fileAnticipator.getTempDir());
m_resourceStorageDao.setRrdStrategy(rrdStrategy);
m_easyMockUtils.replayAll();
InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/collectdconfiguration-testdata.xml");
m_collectdConfig = new CollectdConfigFactory(stream, "localhost", false);
m_easyMockUtils.verifyAll();
m_resourceDao = new DefaultResourceDao();
m_resourceDao.setNodeDao(m_nodeDao);
m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
m_resourceDao.setCollectdConfig(m_collectdConfig);
m_resourceDao.setResourceTypesDao(m_resourceTypesDao);
m_resourceDao.setResourceStorageDao(m_resourceStorageDao);
}
use of org.opennms.netmgt.config.CollectdConfigFactory in project opennms by OpenNMS.
the class ResourceDaoIntegrityIT method setUp.
@Before
public void setUp() throws Exception {
setStoreByForeignSource(false);
m_easyMockUtils = new EasyMockUtils();
m_resourceTypesDao = m_easyMockUtils.createMock(ResourceTypesDao.class);
m_filterDao = m_easyMockUtils.createMock(FilterDao.class);
FilterDaoFactory.setInstance(m_filterDao);
expect(m_filterDao.getActiveIPAddressList("IPADDR IPLIKE *.*.*.*")).andReturn(new ArrayList<InetAddress>(0)).anyTimes();
m_easyMockUtils.replayAll();
InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/collectdconfiguration-testdata.xml");
m_collectdConfig = new CollectdConfigFactory(stream, "localhost", false);
m_easyMockUtils.verifyAll();
m_resourceStorageDao.setRrdDirectory(m_tempFolder.getRoot());
// Match up with the extensions in resource-tree-files.txt
m_resourceStorageDao.setRrdExtension(".rrd");
m_resourceDao = new DefaultResourceDao();
m_resourceDao.setNodeDao(m_nodeDao);
m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
m_resourceDao.setCollectdConfig(m_collectdConfig);
m_resourceDao.setResourceStorageDao(m_resourceStorageDao);
m_resourceDao.setResourceTypesDao(m_resourceTypesDao);
m_resourceDao.setIpInterfaceDao(m_ipInterfaceDao);
}
Aggregations