Search in sources :

Example 36 with ServiceParameters

use of org.opennms.netmgt.collection.api.ServiceParameters in project opennms by OpenNMS.

the class CollectionResourceWrapperIT method createNodeResource.

private SnmpCollectionResource createNodeResource(SnmpCollectionAgent agent) {
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    NodeResourceType resourceType = new NodeResourceType(agent, collection);
    return new NodeInfo(resourceType, agent);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) HashMap(java.util.HashMap) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection)

Example 37 with ServiceParameters

use of org.opennms.netmgt.collection.api.ServiceParameters in project opennms by OpenNMS.

the class TcpOutputStrategyTest method persist.

public void persist(CollectionSet collectionSet, boolean forceStoreByGroup) {
    ServiceParameters params = new ServiceParameters(Collections.emptyMap());
    RrdRepository repo = new RrdRepository();
    repo.setRrdBaseDir(tempFolder.getRoot());
    Persister persister = persisterFactory.createPersister(params, repo, false, forceStoreByGroup, false);
    collectionSet.visit(persister);
}
Also used : ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) Persister(org.opennms.netmgt.collection.api.Persister) RrdRepository(org.opennms.netmgt.rrd.RrdRepository)

Example 38 with ServiceParameters

use of org.opennms.netmgt.collection.api.ServiceParameters in project opennms by OpenNMS.

the class CollectionSetDTO method buildCollectionResources.

private Set<CollectionResource> buildCollectionResources() {
    final Set<CollectionResource> collectionResources = new LinkedHashSet<>();
    for (CollectionResourceDTO entry : this.collectionResources) {
        final Resource resource = entry.getResource();
        final AbstractCollectionResource collectionResource = CollectionSetBuilder.toCollectionResource(resource, agent);
        for (Attribute<?> attribute : entry.getAttributes()) {
            final AttributeGroupType groupType = new AttributeGroupType(attribute.getGroup(), AttributeGroupType.IF_TYPE_ALL);
            final AbstractCollectionAttributeType attributeType = new AbstractCollectionAttributeType(groupType) {

                @Override
                public AttributeType getType() {
                    return attribute.getType();
                }

                @Override
                public String getName() {
                    return attribute.getName();
                }

                @Override
                public void storeAttribute(CollectionAttribute collectionAttribute, Persister persister) {
                    if (AttributeType.STRING.equals(attribute.getType())) {
                        persister.persistStringAttribute(collectionAttribute);
                    } else {
                        persister.persistNumericAttribute(collectionAttribute);
                    }
                }

                @Override
                public String toString() {
                    return attribute.toString();
                }
            };
            collectionResource.addAttribute(new AbstractCollectionAttribute(attributeType, collectionResource) {

                @Override
                public String getMetricIdentifier() {
                    return attribute.getName();
                }

                @Override
                public Number getNumericValue() {
                    return attribute.getNumericValue();
                }

                @Override
                public String getStringValue() {
                    return attribute.getStringValue();
                }

                @Override
                public boolean shouldPersist(ServiceParameters params) {
                    return !(Boolean.FALSE.equals(disableCounterPersistence) && AttributeType.COUNTER.equals(attribute.getType()));
                }

                @Override
                public String toString() {
                    return String.format("Attribute[%s:%s]", getMetricIdentifier(), attribute.getValue());
                }
            });
        }
        collectionResources.add(collectionResource);
    }
    return collectionResources;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) CollectionResource(org.opennms.netmgt.collection.api.CollectionResource) AbstractCollectionResource(org.opennms.netmgt.collection.support.AbstractCollectionResource) AbstractCollectionAttribute(org.opennms.netmgt.collection.support.AbstractCollectionAttribute) CollectionResource(org.opennms.netmgt.collection.api.CollectionResource) AbstractCollectionResource(org.opennms.netmgt.collection.support.AbstractCollectionResource) Resource(org.opennms.netmgt.collection.support.builder.Resource) AbstractCollectionAttribute(org.opennms.netmgt.collection.support.AbstractCollectionAttribute) CollectionAttribute(org.opennms.netmgt.collection.api.CollectionAttribute) AttributeGroupType(org.opennms.netmgt.collection.api.AttributeGroupType) Persister(org.opennms.netmgt.collection.api.Persister) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) AbstractCollectionResource(org.opennms.netmgt.collection.support.AbstractCollectionResource) AbstractCollectionAttributeType(org.opennms.netmgt.collection.support.AbstractCollectionAttributeType)

Example 39 with ServiceParameters

use of org.opennms.netmgt.collection.api.ServiceParameters in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createGenericIndexResourceType.

private GenericIndexResourceType createGenericIndexResourceType(SnmpCollectionAgent agent, String resourceTypeName) {
    org.opennms.netmgt.config.datacollection.ResourceType type = createIndexResourceType(agent, resourceTypeName);
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    return new GenericIndexResourceType(agent, collection, type);
}
Also used : HashMap(java.util.HashMap) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection) GenericIndexResourceType(org.opennms.netmgt.collectd.GenericIndexResourceType)

Example 40 with ServiceParameters

use of org.opennms.netmgt.collection.api.ServiceParameters in project opennms by OpenNMS.

the class SnmpCollectorITCase method initializeAgent.

protected void initializeAgent() throws CollectionInitializationException {
    ServiceParameters params = new ServiceParameters(new HashMap<String, Object>());
    OnmsSnmpCollection snmpCollection = new OnmsSnmpCollection(m_agent, params, m_config, m_locationAwareSnmpClient);
    m_collectionSet = snmpCollection.createCollectionSet(m_agent);
    m_agent.validateAgent();
}
Also used : MibObject(org.opennms.netmgt.config.datacollection.MibObject) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters)

Aggregations

ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)44 HashMap (java.util.HashMap)27 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)19 Test (org.junit.Test)18 CollectionSetVisitor (org.opennms.netmgt.collection.api.CollectionSetVisitor)15 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)14 File (java.io.File)10 CollectionSet (org.opennms.netmgt.collection.api.CollectionSet)10 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)9 MibObject (org.opennms.netmgt.config.datacollection.MibObject)9 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)7 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)7 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)6 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)6 Datasource (org.jrobin.core.Datasource)5 RrdDb (org.jrobin.core.RrdDb)5 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)5 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)5 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)5 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)4