public void addCollector(final String service, final String className) { m_collectors.add(new Collector(service, className)); }
/** * Gets the JMX services. * * @param config the Collectd's configuration * @return the list of JMX services */ private List<String> getJmxServices(CollectdConfiguration config) { List<String> services = new ArrayList<>(); for (Collector c : config.getCollectors()) { // The following code has been made that way to avoid a dependency with opennms-services // TODO Depends on opennms-services is not that bad, considering that some customers could have different implementations. if (c.getClassName().matches(".*(JBoss|JMXSecure|Jsr160|MX4J)Collector$")) { services.add(c.getService()); } } return services; }
private void setupCollector(String svcName, ServiceCollector svcCollector) throws CollectionInitializationException { MockServiceCollector.setDelegate(svcCollector); // Tell the config to use the MockServiceCollector for the specified service Collector collector = new Collector(); collector.setService(svcName); collector.setClassName(MockServiceCollector.class.getName()); m_collectdConfigFactory = m_easyMockUtils.createMock(CollectdConfigFactory.class); m_collectdConfig = m_easyMockUtils.createMock(CollectdConfiguration.class); expect(m_collectdConfigFactory.getCollectdConfig()).andReturn(m_collectdConfig).anyTimes(); expect(m_collectdConfig.getCollectors()).andReturn(Collections.singletonList(collector)).anyTimes(); expect(m_collectdConfig.getThreads()).andReturn(1).anyTimes(); m_collectd.setCollectdConfigFactory(m_collectdConfigFactory); } }
Collector collector = new Collector(); collector.setService("SNMP"); collector.setClassName(MockServiceCollector.class.getName()); param.setKey(TEST_KEY_PARM_NAME); param.setValue(m_key); collector.addParameter(param);
public CollectdConfiguration getCollectdConfigurationForPackages(List<String> collectionPackageNames) { if (collectionPackageNames == null || collectionPackageNames.size() < 1) return null; final Set<String> seenCollectors = new HashSet<>(); final CollectdConfiguration newConfig = new CollectdConfiguration(); newConfig.setThreads(getThreads()); // Add all requested polling packages to the config boolean foundPackage = false; for (String packageName : collectionPackageNames) { final Package pkg = getPackage(packageName); if (pkg != null) { newConfig.addPackage(pkg); foundPackage = true; for (final Service service : pkg.getServices()) { seenCollectors.add(service.getName()); } } } // If the list of polling packages doesn't match anything, then return null if (!foundPackage) return null; for (final Collector collector : getCollectors()) { if (seenCollectors.contains(collector.getService())) { newConfig.addCollector(collector); } } return newConfig; }
Collector collector = new Collector(); collector.setService(getServiceName()); collector.setClassName("org.opennms.netmgt.collectd.Jsr160Collector");
Collector collector = new Collector(); collector.setService(getServiceName()); collector.setClassName("org.opennms.netmgt.collectd.Jsr160Collector");
private void instantiateCollectors() { LOG.debug("instantiateCollectors: Loading collectors"); /* * Load up an instance of each collector from the config * so that the event processor will have them for * new incoming events to create collectable service objects. */ Collection<Collector> collectors = m_collectdConfigFactory.getCollectdConfig().getCollectors(); for (Collector collector : collectors) { String svcName = collector.getService(); try { LOG.debug("instantiateCollectors: Loading collector {}, classname {}", svcName, collector.getClassName()); final ServiceCollector sc = m_serviceCollectorRegistry.getCollectorByClassName(collector.getClassName()); if (sc == null) { throw new IllegalArgumentException(String.format("No collector found with class name '%s'. Available collectors include: %s", collector.getClassName(), m_serviceCollectorRegistry.getCollectorClassNames())); } sc.initialize(); setServiceCollector(svcName, sc); } catch (Throwable t) { LOG.warn("instantiateCollectors: Failed to load collector {} for service {}", collector.getClassName(), svcName, t); } } }
System.setProperty("opennms.home", homeDir.getAbsolutePath()); Collector collector = new Collector(); collector.setService("SNMP"); collector.setClassName(MockServiceCollector.class.getName());
String svcName = collector.getService(); configuredCollectors.add(svcName); if (getServiceCollector(svcName) == null) { try { LOG.debug("rebuildScheduler: Loading collector {}, classname {}", svcName, collector.getClassName()); Class<?> cc = Class.forName(collector.getClassName()); ServiceCollector sc = (ServiceCollector) cc.newInstance(); sc.initialize(); setServiceCollector(svcName, sc); } catch (Throwable t) { LOG.warn("rebuildScheduler: Failed to load collector {} for service {}", collector.getClassName(), svcName, t);