Search in sources :

Example 6 with Package

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;
}
Also used : CollectdConfiguration(org.opennms.netmgt.config.collectd.CollectdConfiguration) Package(org.opennms.netmgt.config.collectd.Package) LinkedList(java.util.LinkedList)

Example 7 with Package

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;
}
Also used : CollectdConfiguration(org.opennms.netmgt.config.collectd.CollectdConfiguration) Collector(org.opennms.netmgt.config.collectd.Collector) Service(org.opennms.netmgt.config.collectd.Service) Package(org.opennms.netmgt.config.collectd.Package)

Example 8 with Package

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);
}
Also used : HashMap(java.util.HashMap) Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package) CollectionSet(org.opennms.netmgt.collection.api.CollectionSet)

Example 9 with Package

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;
}
Also used : Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Example 10 with Package

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;
}
Also used : Filter(org.opennms.netmgt.config.collectd.Filter) Service(org.opennms.netmgt.config.collectd.Service) Parameter(org.opennms.netmgt.config.collectd.Parameter) Package(org.opennms.netmgt.config.collectd.Package)

Aggregations

Package (org.opennms.netmgt.config.collectd.Package)10 Service (org.opennms.netmgt.config.collectd.Service)7 Filter (org.opennms.netmgt.config.collectd.Filter)6 Parameter (org.opennms.netmgt.config.collectd.Parameter)4 CollectdConfiguration (org.opennms.netmgt.config.collectd.CollectdConfiguration)2 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 TreeMap (java.util.TreeMap)1 Before (org.junit.Before)1 Test (org.junit.Test)1 MockRpcClientFactory (org.opennms.core.rpc.mock.MockRpcClientFactory)1 MockPlatformTransactionManager (org.opennms.core.test.MockPlatformTransactionManager)1 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)1 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)1 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)1 Collector (org.opennms.netmgt.config.collectd.Collector)1 MibObject (org.opennms.netmgt.config.datacollection.MibObject)1 Parameter (org.opennms.netmgt.config.datacollection.Parameter)1 PersistenceSelectorStrategy (org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy)1