Search in sources :

Example 11 with SnmpAttribute

use of org.opennms.netmgt.collectd.SnmpAttribute 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)

Aggregations

SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)11 HashMap (java.util.HashMap)9 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)9 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)9 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)9 Test (org.junit.Test)8 Date (java.util.Date)4 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)4 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)4 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)4 IfResourceType (org.opennms.netmgt.collectd.IfResourceType)3 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)3 SnmpAttributeType (org.opennms.netmgt.collectd.SnmpAttributeType)3 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)3 MibObject (org.opennms.netmgt.config.datacollection.MibObject)3 BigInteger (java.math.BigInteger)2 GenericIndexResource (org.opennms.netmgt.collectd.GenericIndexResource)2 GenericIndexResourceType (org.opennms.netmgt.collectd.GenericIndexResourceType)2 NumericAttributeType (org.opennms.netmgt.collectd.NumericAttributeType)2 Parameter (org.opennms.netmgt.config.datacollection.Parameter)2