本文整理汇总了Java中org.opennms.netmgt.config.CollectdConfigFactory类的典型用法代码示例。如果您正苦于以下问题:Java CollectdConfigFactory类的具体用法?Java CollectdConfigFactory怎么用?Java CollectdConfigFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CollectdConfigFactory类属于org.opennms.netmgt.config包,在下文中一共展示了CollectdConfigFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
@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_dataCollectionConfigDao = m_easyMockUtils.createMock(DataCollectionConfigDao.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_resourceDao = new DefaultResourceDao();
m_resourceDao.setNodeDao(m_nodeDao);
m_resourceDao.setLocationMonitorDao(m_locationMonitorDao);
m_resourceDao.setCollectdConfig(m_collectdConfig);
m_resourceDao.setRrdDirectory(m_fileAnticipator.getTempDir());
m_resourceDao.setDataCollectionConfigDao(m_dataCollectionConfigDao);
RrdUtils.setStrategy(new JRobinRrdStrategy());
}
示例2: getJmxResourceDirectories
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
/**
* Gets the JMX resource directories.
*
* @return the JMX resource directories
* @throws OnmsUpgradeException the OpenNMS upgrade exception
*/
private List<File> getJmxResourceDirectories() throws OnmsUpgradeException {
if (jmxResourceDirectories == null) {
jmxResourceDirectories = new ArrayList<File>();
CollectdConfiguration config;
try {
config = CollectdConfigFactory.getInstance().getCollectdConfig().getConfig();
} catch (Exception e) {
throw new OnmsUpgradeException("Can't upgrade the JRBs because " + e.getMessage(), e);
}
List<String> services = getJmxServices(config);
log("JMX services found: %s\n", services);
List<String> jmxFriendlyNames = new ArrayList<String>();
for (String service : services) {
Service svc = getServiceObject(config, service);
String friendlyName = getSvcPropertyValue(svc, "friendly-name");
if (friendlyName == null) {
friendlyName = getSvcPropertyValue(svc, "port"); // According with JMXCollector, port will be used if there is no friendly-name.
}
if (friendlyName == null) {
log("Warning: there is no friendly-name or port parameter for service %s. The JRBs/RRDs for this service are not going to be updated.", service);
} else {
jmxFriendlyNames.add(friendlyName);
}
}
log("JMX friendly names found: %s\n", jmxFriendlyNames);
File rrdDir = new File(JMXDataCollectionConfigFactory.getInstance().getRrdPath());
findJmxDirectories(rrdDir, jmxFriendlyNames, jmxResourceDirectories);
if (jmxResourceDirectories.isEmpty()) {
log("Warning: no JMX directories found on %s\n", rrdDir);
}
}
return jmxResourceDirectories;
}
示例3: handleScheduledOutagesChanged
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private void handleScheduledOutagesChanged(Event event) {
try {
log().info("Reloading Collectd config factory");
CollectdConfigFactory.reload();
refreshServicePackages();
} catch (Throwable e) {
log().error(
"Failed to reload CollectdConfigFactory because "
+ e.getMessage(), e);
}
}
示例4: initialize
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private CollectorConfigDao initialize() throws IOException, MarshalException, ValidationException, Exception {
System.setProperty("opennms.home", ConfigurationTestUtils.getDaemonEtcDirectory().getParentFile().getAbsolutePath());
RrdUtils.setStrategy(new JRobinRrdStrategy());
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/jmx-datacollection-testdata.xml");
JMXDataCollectionConfigFactory.setInstance(new JMXDataCollectionConfigFactory(stream));
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/snmp-config.xml");
SnmpPeerFactory.setInstance(new SnmpPeerFactory(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");
CollectdConfigFactory.setInstance(new CollectdConfigFactory(stream, "localhost", false));
stream.close();
return new CollectorConfigDaoImpl();
}
示例5: testPersistApacheStatsViaCapsd
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
@Test
@JUnitHttpServer(port=10342, vhosts={"127.0.0.1"})
@JUnitCollector(
datacollectionConfig="/org/opennms/netmgt/config/http-datacollection-persist-apache-stats.xml",
datacollectionType="http",
anticipateRrds={
"1/TotalAccesses",
"1/TotalkBytes",
"1/CPULoad",
"1/Uptime",
"1/ReqPerSec",
"1/BytesPerSec",
"1/BytesPerReq",
"1/BusyWorkers",
"1/IdleWorkers"
}
)
public void testPersistApacheStatsViaCapsd() throws Exception {
// TODO: Do we need this init? applicationContext-collectdTest.xml should take care of this
CollectdConfigFactory collectdConfig = new CollectdConfigFactory(ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/collectd-configuration.xml"), "nms1", false);
CollectdConfigFactory.setInstance(collectdConfig);
CollectdConfigFactory.init();
// Add the HTTP collector to capsd
m_collectd.setServiceCollector("HTTP", m_collector);
m_collectd.init();
m_collectd.start();
Thread.sleep(10000);
m_collectd.stop();
}
示例6: initialize
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private CollectorConfigDao initialize() throws IOException, MarshalException, ValidationException, Exception {
System.setProperty("opennms.home", ConfigurationTestUtils.getDaemonEtcDirectory().getParentFile().getAbsolutePath());
RrdTestUtils.initialize();
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/jmx-datacollection-testdata.xml");
JMXDataCollectionConfigFactory.setInstance(new JMXDataCollectionConfigFactory(stream));
stream.close();
stream = getInputStreamForFile("/org/opennms/netmgt/config/snmp-config.xml");
SnmpPeerFactory.setInstance(new SnmpPeerFactory(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");
CollectdConfigFactory.setInstance(new CollectdConfigFactory(stream, "localhost", false));
stream.close();
return new CollectorConfigDaoImpl();
}
示例7: readCollectdConfiguration
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private CollectdConfig readCollectdConfiguration() throws MarshalException, ValidationException, IOException, FileNotFoundException {
CollectdConfigFactory.init();
CollectdConfigFactory collectdConfigFactory = new CollectdConfigFactory(new FileInputStream(new File(CONFIG_FOLDER.concat(File.separator + CONFIG_FILE))), "LocalServer?", false);
return collectdConfigFactory.getCollectdConfig();
}
示例8: setUpCollectdConfigFactory
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private void setUpCollectdConfigFactory() throws MarshalException, ValidationException, IOException {
InputStream stream = ConfigurationTestUtils.getInputStreamForResource(this, "/collectdconfiguration-testdata.xml");
m_collectdConfig = new CollectdConfigFactory(stream, "localhost", false);
stream.close();
}
示例9: getCollectdPackage
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private CollectdPackage getCollectdPackage(String packageName) throws IllegalArgumentException {
CollectdPackage pkg = CollectdConfigFactory.getInstance().getPackage(packageName);
if (pkg == null) throw new IllegalArgumentException("Collectd package " + packageName + " does not exist.");
return pkg;
}
示例10: getConfig
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
private CollectdConfig getConfig() {
return CollectdConfigFactory.getInstance().getCollectdConfig();
}
示例11: setUp
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
MockDatabase db = new MockDatabase();
DataSourceFactory.setInstance(db);
RrdUtils.setStrategy(m_strategy);
m_provisioner = new OpenNMSProvisioner();
m_eventManager = new MockEventIpcManager();
m_provisioner.setEventManager(m_eventManager);
m_capsdConfig = new TestCapsdConfigManager(CAPSD_CONFIG);
CapsdConfigFactory.setInstance(m_capsdConfig);
m_pollerConfig = new TestPollerConfigManager(POLLER_CONFIG, "localhost", false);
PollerConfigFactory.setInstance(m_pollerConfig);
m_provisioner.setCapsdConfig(m_capsdConfig);
m_provisioner.setPollerConfig(m_pollerConfig);
InputStream configStream = ConfigurationTestUtils.getInputStreamForConfigFile("opennms-server.xml");
OpennmsServerConfigFactory onmsSvrConfig = new OpennmsServerConfigFactory(configStream);
configStream.close();
OpennmsServerConfigFactory.setInstance(onmsSvrConfig);
configStream = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(configStream));
configStream.close();
configStream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/collectd-configuration.xml");
CollectdConfigFactory.setInstance(new CollectdConfigFactory(configStream, onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer()));
configStream.close();
JdbcTemplate jdbcTemplate = new JdbcTemplate(db);
m_syncer = new JdbcCapsdDbSyncer();
m_syncer.setJdbcTemplate(jdbcTemplate);
m_syncer.setOpennmsServerConfig(OpennmsServerConfigFactory.getInstance());
m_syncer.setCapsdConfig(m_capsdConfig);
m_syncer.setPollerConfig(m_pollerConfig);
m_syncer.setCollectdConfig(CollectdConfigFactory.getInstance());
m_syncer.setNextSvcIdSql(db.getNextServiceIdStatement());
m_syncer.afterPropertiesSet();
m_syncer.syncServices();
m_provisioner.setCapsdDbSyncer(m_syncer);
}
示例12: testNodeGainedDynamicService
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
@Test
public void testNodeGainedDynamicService() throws Exception {
m_pollerConfig.setNodeOutageProcessingEnabled(true);
startDaemons();
TestCapsdConfigManager capsdConfig = new TestCapsdConfigManager(CAPSD_CONFIG);
InputStream configStream = ConfigurationTestUtils.getInputStreamForConfigFile("opennms-server.xml");
OpennmsServerConfigFactory onmsSvrConfig = new OpennmsServerConfigFactory(configStream);
configStream.close();
configStream = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(configStream));
configStream.close();
configStream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/collectd-configuration.xml");
CollectdConfigFactory collectdConfig = new CollectdConfigFactory(configStream, onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer());
configStream.close();
JdbcTemplate jdbcTemplate = new JdbcTemplate(m_db);
JdbcCapsdDbSyncer syncer = new JdbcCapsdDbSyncer();
syncer.setJdbcTemplate(jdbcTemplate);
syncer.setOpennmsServerConfig(onmsSvrConfig);
syncer.setCapsdConfig(capsdConfig);
syncer.setPollerConfig(m_pollerConfig);
syncer.setCollectdConfig(collectdConfig);
syncer.setNextSvcIdSql(m_db.getNextServiceIdStatement());
syncer.afterPropertiesSet();
OpenNMSProvisioner provisioner = new OpenNMSProvisioner();
provisioner.setPollerConfig(m_pollerConfig);
provisioner.setCapsdConfig(capsdConfig);
provisioner.setCapsdDbSyncer(syncer);
provisioner.setEventManager(m_eventMgr);
provisioner.addServiceDNS("MyDNS", 3, 100, 1000, 500, 3000, 53,
"www.opennms.org");
assertNotNull("The service id for MyDNS is null", m_db
.getServiceID("MyDNS"));
MockUtil.println("The service id for MyDNS is: "
+ m_db.getServiceID("MyDNS").toString());
m_anticipator.reset();
testSendNodeGainedService("MyDNS", "HTTP");
}
示例13: setUp
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
m_agent = MockSnmpAgent.createAgentAndRun(new ClassPathResource("org/opennms/netmgt/snmp/snmpTestData1.properties"), InetAddressUtils.str(this.myLocalHost()) + "/9161");
InputStream configStream = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory.setInstance(new DatabaseSchemaConfigFactory(configStream));
configStream.close();
configStream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/capsd-configuration.xml");
DefaultCapsdConfigManager capsdConfig = new DefaultCapsdConfigManager(configStream);
configStream.close();
CapsdConfigFactory.setInstance(capsdConfig);
configStream = ConfigurationTestUtils.getInputStreamForConfigFile("opennms-server.xml");
OpennmsServerConfigFactory onmsSvrConfig = new OpennmsServerConfigFactory(configStream);
configStream.close();
OpennmsServerConfigFactory.setInstance(onmsSvrConfig);
configStream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/poller-configuration.xml");
PollerConfigFactory.setInstance(new PollerConfigFactory(System.currentTimeMillis(), configStream, onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer()));
configStream.close();
RrdTestUtils.initialize();
configStream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/collectd-configuration.xml");
CollectdConfigFactory.setInstance(new CollectdConfigFactory(configStream, onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer()));
configStream.close();
JdbcTemplate jdbcTemplate = new JdbcTemplate(m_db);
JdbcCapsdDbSyncer syncer = new JdbcCapsdDbSyncer();
syncer.setJdbcTemplate(jdbcTemplate);
syncer.setOpennmsServerConfig(OpennmsServerConfigFactory.getInstance());
syncer.setCapsdConfig(CapsdConfigFactory.getInstance());
syncer.setPollerConfig(PollerConfigFactory.getInstance());
syncer.setCollectdConfig(CollectdConfigFactory.getInstance());
syncer.setNextSvcIdSql(m_db.getNextServiceIdStatement());
syncer.afterPropertiesSet();
PluginManager pluginManager = new PluginManager();
pluginManager.setCapsdConfig(capsdConfig);
pluginManager.afterPropertiesSet();
DefaultProcessorFactory defaultProcessorFactory = new DefaultProcessorFactory();
defaultProcessorFactory.setCapsdDbSyncer(syncer);
defaultProcessorFactory.setPluginManager(pluginManager);
RunnableConsumerThreadPool suspectRunner =
new RunnableConsumerThreadPool("SuspectRunner", 0.0f, 0.0f, 1);
RunnableConsumerThreadPool rescanRunner =
new RunnableConsumerThreadPool("RescanRunner", 0.0f, 0.0f, 1);
Scheduler scheduler = new Scheduler(rescanRunner.getRunQueue(), defaultProcessorFactory);
BroadcastEventProcessor eventHandler = new BroadcastEventProcessor();
eventHandler.setSuspectEventProcessorFactory(defaultProcessorFactory);
eventHandler.setLocalServer("localhost");
eventHandler.setScheduler(scheduler);
eventHandler.setSuspectQueue(suspectRunner.getRunQueue());
eventHandler.afterPropertiesSet();
AnnotationBasedEventListenerAdapter adapter =
new AnnotationBasedEventListenerAdapter(eventHandler, m_eventdIpcMgr);
m_capsd = new Capsd();
m_capsd.setCapsdDbSyncer(syncer);
m_capsd.setSuspectEventProcessorFactory(defaultProcessorFactory);
m_capsd.setCapsdConfig(capsdConfig);
m_capsd.setSuspectRunner(suspectRunner);
m_capsd.setRescanRunner(rescanRunner);
m_capsd.setScheduler(scheduler);
m_capsd.setEventListener(adapter);
m_capsd.afterPropertiesSet();
}
示例14: setUp
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
System.setProperty("opennms.db.nextNodeId", "select max(nodeId) + 1 from node");
super.setUp();
m_agent = MockSnmpAgent.createAgentAndRun(new ClassPathResource("org/opennms/netmgt/snmp/stonegate.properties"), InetAddressUtils.str(this.myLocalHost()) + "/9161");
InputStream configStream = ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/capsd-configuration.xml");
DefaultCapsdConfigManager capsdConfig = new DefaultCapsdConfigManager(configStream);
configStream.close();
CapsdConfigFactory.setInstance(capsdConfig);
configStream = ConfigurationTestUtils.getInputStreamForConfigFile("database-schema.xml");
DatabaseSchemaConfigFactory dbConfigFactory = new DatabaseSchemaConfigFactory(configStream);
configStream.close();
DatabaseSchemaConfigFactory.setInstance(dbConfigFactory);
OpennmsServerConfigFactory onmsSvrConfig = new OpennmsServerConfigFactory(ConfigurationTestUtils.getInputStreamForConfigFile("opennms-server.xml"));
OpennmsServerConfigFactory.setInstance(onmsSvrConfig);
PollerConfigFactory.setInstance(new PollerConfigFactory(System.currentTimeMillis(), ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/poller-configuration.xml"), onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer()));
RrdTestUtils.initialize();
CollectdConfigFactory.setInstance(new CollectdConfigFactory(ConfigurationTestUtils.getInputStreamForResource(this, "/org/opennms/netmgt/capsd/collectd-configuration.xml"), onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer()));
JdbcTemplate jdbcTemplate = new JdbcTemplate(m_db);
JdbcCapsdDbSyncer syncer = new JdbcCapsdDbSyncer();
syncer.setJdbcTemplate(jdbcTemplate);
syncer.setOpennmsServerConfig(OpennmsServerConfigFactory.getInstance());
syncer.setCapsdConfig(CapsdConfigFactory.getInstance());
syncer.setPollerConfig(PollerConfigFactory.getInstance());
syncer.setCollectdConfig(CollectdConfigFactory.getInstance());
syncer.setNextSvcIdSql(m_db.getNextServiceIdStatement());
syncer.afterPropertiesSet();
PluginManager pluginManager = new PluginManager();
pluginManager.setCapsdConfig(capsdConfig);
pluginManager.afterPropertiesSet();
DefaultProcessorFactory defaultProcessorFactory = new DefaultProcessorFactory();
defaultProcessorFactory.setCapsdDbSyncer(syncer);
defaultProcessorFactory.setPluginManager(pluginManager);
RunnableConsumerThreadPool suspectRunner =
new RunnableConsumerThreadPool("SuspectRunner", 0.0f, 0.0f, 1);
RunnableConsumerThreadPool rescanRunner =
new RunnableConsumerThreadPool("RescanRunner", 0.0f, 0.0f, 1);
Scheduler scheduler = new Scheduler(rescanRunner.getRunQueue(), defaultProcessorFactory);
BroadcastEventProcessor eventHandler = new BroadcastEventProcessor();
eventHandler.setSuspectEventProcessorFactory(defaultProcessorFactory);
eventHandler.setLocalServer("localhost");
eventHandler.setScheduler(scheduler);
eventHandler.setSuspectQueue(suspectRunner.getRunQueue());
eventHandler.afterPropertiesSet();
AnnotationBasedEventListenerAdapter adapter =
new AnnotationBasedEventListenerAdapter(eventHandler, m_eventdIpcMgr);
m_capsd = new Capsd();
m_capsd.setCapsdDbSyncer(syncer);
m_capsd.setSuspectEventProcessorFactory(defaultProcessorFactory);
m_capsd.setCapsdConfig(capsdConfig);
m_capsd.setSuspectRunner(suspectRunner);
m_capsd.setRescanRunner(rescanRunner);
m_capsd.setScheduler(scheduler);
m_capsd.setEventListener(adapter);
m_capsd.afterPropertiesSet();
}
示例15: getCollectdConfig
import org.opennms.netmgt.config.CollectdConfigFactory; //导入依赖的package包/类
/**
* <p>getCollectdConfig</p>
*
* @return a {@link org.opennms.netmgt.config.CollectdConfigFactory} object.
*/
public CollectdConfigFactory getCollectdConfig() {
return m_collectdConfig;
}