use of org.opennms.netmgt.config.collectd.Package in project opennms by OpenNMS.
the class Collectd method getSpecificationsForInterface.
/**
* <p>getSpecificationsForInterface</p>
*
* @param iface a {@link org.opennms.netmgt.model.OnmsIpInterface} object.
* @param svcName a {@link java.lang.String} object.
* @return a {@link java.util.Collection} object.
*/
public Collection<CollectionSpecification> getSpecificationsForInterface(OnmsIpInterface iface, String svcName) {
Collection<CollectionSpecification> matchingPkgs = new LinkedList<CollectionSpecification>();
CollectdConfiguration collectdConfig = m_collectdConfigFactory.getCollectdConfig();
/*
* Compare interface/service pair against each collectd package
* For each match, create new SnmpCollector object and
* schedule it for collection
*/
for (Package wpkg : collectdConfig.getPackages()) {
/*
* Make certain the the current service is in the package
* and enabled!
*/
if (!wpkg.serviceInPackageAndEnabled(svcName)) {
LOG.debug("getSpecificationsForInterface: address/service: {}/{} not scheduled, service is not enabled or does not exist in package: {}", iface, svcName, wpkg.getName());
continue;
}
// Ensure that the package is not a remote package
if (wpkg.isRemote()) {
LOG.debug("getSpecificationsForInterface: address/service: {}/{} not scheduled, package {} is a remote package.", iface, svcName, wpkg.getName());
continue;
}
// Is the interface in the package?
if (!m_collectdConfigFactory.interfaceInPackage(iface, wpkg)) {
LOG.debug("getSpecificationsForInterface: address/service: {}/{} not scheduled, interface does not belong to package: {}", iface, svcName, wpkg.getName());
continue;
}
LOG.debug("getSpecificationsForInterface: address/service: {}/{} scheduled, interface does belong to package: {}", iface, svcName, wpkg.getName());
matchingPkgs.add(new CollectionSpecification(wpkg, svcName, getServiceCollector(svcName), instrumentation(), m_locationAwareCollectorClient));
}
return matchingPkgs;
}
use of org.opennms.netmgt.config.collectd.Package in project opennms by OpenNMS.
the class UiModel method getCollectdConfiguration.
/**
* Creates a CollectdConfiguration snippet depending on the data saved here.
*
* @return The CollecdConfiguration snippet depending on the data saved in
* this model.
*/
public CollectdConfiguration getCollectdConfiguration() {
CollectdConfiguration config = new CollectdConfiguration();
// set default package
Package defaultPackage = new Package();
defaultPackage.setName("default");
// set service
Service service = new Service();
service.setName(getServiceName());
service.setInterval(300000L);
service.setUserDefined(Boolean.TRUE.toString());
service.setStatus("on");
// add parameters to service
service.addParameter(createParameter("url", getServiceConfig().getConnection()));
service.addParameter(createParameter("retry", "2"));
service.addParameter(createParameter("timeout", "3000"));
service.addParameter(createParameter("rrd-base-name", "java"));
service.addParameter(createParameter("ds-name", getServiceName()));
service.addParameter(createParameter("friendly-name", getServiceName()));
service.addParameter(createParameter("collection", getServiceName()));
service.addParameter(createParameter("thresholding-enabled", Boolean.TRUE.toString()));
// If we used credentials, we set them here as well
if (getServiceConfig().isAuthenticate()) {
service.addParameter(createParameter("factory", "PASSWORD-CLEAR"));
service.addParameter(createParameter("username", getServiceConfig().getUser()));
service.addParameter(createParameter("password", getServiceConfig().getPassword()));
}
// create Collector
Collector collector = new Collector();
collector.setService(getServiceName());
collector.setClassName("org.opennms.netmgt.collectd.Jsr160Collector");
// register service, package and collector to configuration
config.addPackage(defaultPackage);
config.addCollector(collector);
defaultPackage.addService(service);
return config;
}
use of org.opennms.netmgt.config.collectd.Package in project opennms by OpenNMS.
the class HttpCollectorIT method doTestNMS4886.
public final void doTestNMS4886(String svcName) throws Exception {
HttpCollector collector = new HttpCollector();
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("http-collection", "default");
parameters.put("port", "10342");
collector.initialize();
Package pkg = new Package();
Filter filter = new Filter();
filter.setContent("IPADDR IPLIKE *.*.*.*");
pkg.setFilter(filter);
Service service = new Service();
service.setName(svcName);
Parameter collectionParm = new Parameter();
collectionParm.setKey("http-collection");
collectionParm.setValue("default");
service.addParameter(collectionParm);
Parameter portParm = new Parameter();
portParm.setKey("port");
portParm.setValue("10342");
service.addParameter(portParm);
pkg.addService(service);
CollectionSpecification collectionSpecification = new CollectionSpecification(pkg, svcName, collector, new DefaultCollectdInstrumentation(), CollectorTestUtils.createLocationAwareCollectorClient());
CollectionSet collectionSet = collectionSpecification.collect(m_collectionAgent);
assertEquals("collection status", CollectionStatus.SUCCEEDED, collectionSet.getStatus());
CollectorTestUtils.persistCollectionSet(m_rrdStrategy, m_resourceStorageDao, collectionSpecification, collectionSet);
}
use of org.opennms.netmgt.config.collectd.Package in project opennms by OpenNMS.
the class CollectdTest method getCollectionPackageThatMatchesSNMP.
private static Package getCollectionPackageThatMatchesSNMP() {
Package pkg = new Package();
pkg.setName("pkg");
Filter filter = new Filter();
filter.setContent("IPADDR IPLIKE *.*.*.*");
pkg.setFilter(filter);
Service svc = new Service();
pkg.addService(svc);
svc.setName("SNMP");
svc.setStatus("on");
Parameter parm = new Parameter();
parm.setKey("collection");
parm.setValue("default");
svc.addParameter(parm);
parm = new Parameter();
parm.setKey("thresholding-enabled");
parm.setValue("true");
svc.addParameter(parm);
svc.setStatus("on");
return pkg;
}
use of org.opennms.netmgt.config.collectd.Package in project opennms by OpenNMS.
the class CollectorTestUtils method createCollectionSpec.
static CollectionSpecification createCollectionSpec(String svcName, ServiceCollector svcCollector, String collectionName) {
Package pkg = new Package();
Filter filter = new Filter();
filter.setContent("IPADDR IPLIKE *.*.*.*");
pkg.setFilter(filter);
Service service = new Service();
service.setName(svcName);
Parameter collectionParm = new Parameter();
collectionParm.setKey("collection");
collectionParm.setValue(collectionName);
service.addParameter(collectionParm);
pkg.addService(service);
CollectionSpecification spec = new CollectionSpecification(pkg, svcName, svcCollector, new DefaultCollectdInstrumentation(), createLocationAwareCollectorClient());
return spec;
}
Aggregations