Search in sources :

Example 6 with Parameter

use of org.opennms.netmgt.config.datacollection.Parameter 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

Parameter (org.opennms.netmgt.config.datacollection.Parameter)6 PersistenceSelectorStrategy (org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy)5 StorageStrategy (org.opennms.netmgt.config.datacollection.StorageStrategy)5 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)4 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)3 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)3 GenericIndexResource (org.opennms.netmgt.collectd.GenericIndexResource)2 GenericIndexResourceType (org.opennms.netmgt.collectd.GenericIndexResourceType)2 IfResourceType (org.opennms.netmgt.collectd.IfResourceType)2 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)2 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)2 SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)2 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)2 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)2 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)2 Maps (com.google.common.collect.Maps)1 XMLDoc (com.mycila.xmltool.XMLDoc)1 XMLTag (com.mycila.xmltool.XMLTag)1