Search in sources :

Example 6 with OnmsSnmpCollection

use of org.opennms.netmgt.collectd.OnmsSnmpCollection in project opennms by OpenNMS.

the class CollectionResourceWrapperIT method testGenericResource.

@Test
public void testGenericResource() throws Exception {
    SnmpCollectionAgent agent = createCollectionAgent();
    MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
    OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
    ResourceType rt = new ResourceType();
    rt.setName("hrStorageIndex");
    rt.setLabel("host-resources storage");
    StorageStrategy strategy = new StorageStrategy();
    strategy.setClazz("org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy");
    strategy.addParameter(new Parameter("sibling-column-name", "hrStorageLabel"));
    strategy.addParameter(new Parameter("replace-all", "s/^-//"));
    rt.setStorageStrategy(strategy);
    PersistenceSelectorStrategy pstrategy = new PersistenceSelectorStrategy();
    pstrategy.setClazz("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy");
    rt.setPersistenceSelectorStrategy(pstrategy);
    GenericIndexResourceType resourceType = new GenericIndexResourceType(agent, collection, rt);
    SnmpCollectionResource resource = new GenericIndexResource(resourceType, resourceType.getName(), new SnmpInstId(100));
    SnmpAttribute used = addAttributeToCollectionResource(resource, "hrStorageUsed", AttributeType.GAUGE, "hrStorageIndex", "5000");
    SnmpAttribute label = addAttributeToCollectionResource(resource, "hrStorageLabel", AttributeType.STRING, "hrStorageIndex", "/opt");
    Map<String, CollectionAttribute> attributes = new HashMap<String, CollectionAttribute>();
    attributes.put(used.getName(), used);
    attributes.put(label.getName(), label);
    CollectionResourceWrapper wrapper = createWrapper(resource, attributes);
    Assert.assertEquals("opt", wrapper.getInstanceLabel());
}
Also used : StorageStrategy(org.opennms.netmgt.config.datacollection.StorageStrategy) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) HashMap(java.util.HashMap) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) GenericIndexResourceType(org.opennms.netmgt.collectd.GenericIndexResourceType) NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) IfResourceType(org.opennms.netmgt.collectd.IfResourceType) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) GenericIndexResource(org.opennms.netmgt.collectd.GenericIndexResource) GenericIndexResourceType(org.opennms.netmgt.collectd.GenericIndexResourceType) CollectionAttribute(org.opennms.netmgt.collection.api.CollectionAttribute) SnmpAttribute(org.opennms.netmgt.collectd.SnmpAttribute) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) Parameter(org.opennms.netmgt.config.datacollection.Parameter) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection) PersistenceSelectorStrategy(org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy) Test(org.junit.Test)

Example 7 with OnmsSnmpCollection

use of org.opennms.netmgt.collectd.OnmsSnmpCollection 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 8 with OnmsSnmpCollection

use of org.opennms.netmgt.collectd.OnmsSnmpCollection in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createInterfaceResourceType.

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

Example 9 with OnmsSnmpCollection

use of org.opennms.netmgt.collectd.OnmsSnmpCollection in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createNodeResourceType.

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

Aggregations

HashMap (java.util.HashMap)9 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)9 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)9 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)9 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)6 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)5 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)5 Test (org.junit.Test)4 IfResourceType (org.opennms.netmgt.collectd.IfResourceType)4 SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)4 GenericIndexResourceType (org.opennms.netmgt.collectd.GenericIndexResourceType)3 NodeInfo (org.opennms.netmgt.collectd.NodeInfo)3 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)3 GenericIndexResource (org.opennms.netmgt.collectd.GenericIndexResource)2 Parameter (org.opennms.netmgt.config.datacollection.Parameter)2 PersistenceSelectorStrategy (org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy)2 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)2 StorageStrategy (org.opennms.netmgt.config.datacollection.StorageStrategy)2 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)2 MockDatabase (org.opennms.core.test.db.MockDatabase)1