Search in sources :

Example 11 with PersistenceSelectorStrategy

use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createWmiLogicalDiskResourceType.

private static org.opennms.netmgt.config.datacollection.ResourceType createWmiLogicalDiskResourceType() {
    org.opennms.netmgt.config.datacollection.ResourceType wmiLogicalDisk = new org.opennms.netmgt.config.datacollection.ResourceType();
    wmiLogicalDisk.setName("wmiLogicalDisk");
    wmiLogicalDisk.setLabel("(wsman) Logical Storage");
    wmiLogicalDisk.setResourceLabel("Logical Disk (${wmiLDName})");
    PersistenceSelectorStrategy pss = new PersistenceSelectorStrategy();
    pss.setClazz(PersistAllSelectorStrategy.class.getCanonicalName());
    wmiLogicalDisk.setPersistenceSelectorStrategy(pss);
    StorageStrategy ss = new StorageStrategy();
    ss.setClazz(SiblingColumnStorageStrategy.class.getCanonicalName());
    org.opennms.netmgt.config.datacollection.Parameter siblingColumnName = new org.opennms.netmgt.config.datacollection.Parameter();
    siblingColumnName.setKey("sibling-column-name");
    siblingColumnName.setValue("wmiLDName");
    ss.addParameter(siblingColumnName);
    wmiLogicalDisk.setStorageStrategy(ss);
    return wmiLogicalDisk;
}
Also used : StorageStrategy(org.opennms.netmgt.config.datacollection.StorageStrategy) IndexStorageStrategy(org.opennms.netmgt.collection.support.IndexStorageStrategy) SiblingColumnStorageStrategy(org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy) PersistAllSelectorStrategy(org.opennms.netmgt.collection.support.PersistAllSelectorStrategy) GenericIndexResourceType(org.opennms.netmgt.collectd.GenericIndexResourceType) NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) ResourceType(org.opennms.netmgt.collectd.ResourceType) IfResourceType(org.opennms.netmgt.collectd.IfResourceType) Parameter(org.opennms.netmgt.config.threshd.Parameter) SiblingColumnStorageStrategy(org.opennms.netmgt.dao.support.SiblingColumnStorageStrategy) PersistenceSelectorStrategy(org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy)

Example 12 with PersistenceSelectorStrategy

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

use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.

the class GenericIndexResourceTypeTest method instantiate.

private GenericIndexResourceType instantiate() {
    org.opennms.netmgt.config.datacollection.ResourceType rt = new org.opennms.netmgt.config.datacollection.ResourceType();
    PersistenceSelectorStrategy ps = new PersistenceSelectorStrategy();
    ps.setClazz("org.opennms.netmgt.collection.support.PersistAllSelectorStrategy");
    rt.setPersistenceSelectorStrategy(ps);
    StorageStrategy ss = new StorageStrategy();
    ss.setClazz("org.opennms.netmgt.collection.support.IndexStorageStrategy");
    rt.setStorageStrategy(ss);
    return new GenericIndexResourceType(null, null, rt);
}
Also used : StorageStrategy(org.opennms.netmgt.config.datacollection.StorageStrategy) PersistenceSelectorStrategy(org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy)

Example 14 with PersistenceSelectorStrategy

use of org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy in project opennms by OpenNMS.

the class XmpCollectorTest method canDetermineAppropriateResourceType.

@Test
public void canDetermineAppropriateResourceType() throws CollectionException {
    NodeLevelResource nodeLevelResource = new NodeLevelResource(1);
    // Define the resource type
    ResourceType resourceType = new ResourceType();
    resourceType.setName("rt");
    resourceType.setLabel("rt label");
    resourceType.setResourceLabel("${instance}");
    StorageStrategy storageStrategy = new StorageStrategy();
    storageStrategy.setClazz(IndexStorageStrategy.class.getCanonicalName());
    resourceType.setStorageStrategy(storageStrategy);
    PersistenceSelectorStrategy persistenceSelectorStrategy = new PersistenceSelectorStrategy();
    persistenceSelectorStrategy.setClazz(PersistAllSelectorStrategy.class.getCanonicalName());
    resourceType.setPersistenceSelectorStrategy(persistenceSelectorStrategy);
    ResourceTypesDao resourceTypesDao = mock(ResourceTypesDao.class);
    when(resourceTypesDao.getResourceTypeByName(resourceType.getName())).thenReturn(resourceType);
    xmpCollector.setResourceTypesDao(resourceTypesDao);
    // If the nodeTypeName is set to "node" it should always return a node level resource
    assertThat(xmpCollector.getResource(nodeLevelResource, CollectionResource.RESOURCE_TYPE_NODE, null, "instance"), instanceOf(NodeLevelResource.class));
    assertThat(xmpCollector.getResource(nodeLevelResource, CollectionResource.RESOURCE_TYPE_NODE, "some-resource", "instance"), instanceOf(NodeLevelResource.class));
    // If a resource-type is set, it should always return a generic type resource
    assertThat(xmpCollector.getResource(nodeLevelResource, null, "rt", "instance"), instanceOf(GenericTypeResource.class));
    // Otherwise, falls back to an instance level resource
    assertThat(xmpCollector.getResource(nodeLevelResource, null, null, "instance"), instanceOf(InterfaceLevelResource.class));
}
Also used : StorageStrategy(org.opennms.netmgt.config.datacollection.StorageStrategy) IndexStorageStrategy(org.opennms.netmgt.collection.support.IndexStorageStrategy) PersistAllSelectorStrategy(org.opennms.netmgt.collection.support.PersistAllSelectorStrategy) GenericTypeResource(org.opennms.netmgt.collection.support.builder.GenericTypeResource) IndexStorageStrategy(org.opennms.netmgt.collection.support.IndexStorageStrategy) ResourceTypesDao(org.opennms.netmgt.config.api.ResourceTypesDao) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) InterfaceLevelResource(org.opennms.netmgt.collection.support.builder.InterfaceLevelResource) NodeLevelResource(org.opennms.netmgt.collection.support.builder.NodeLevelResource) PersistenceSelectorStrategy(org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy) Test(org.junit.Test)

Aggregations

PersistenceSelectorStrategy (org.opennms.netmgt.config.datacollection.PersistenceSelectorStrategy)14 StorageStrategy (org.opennms.netmgt.config.datacollection.StorageStrategy)14 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)11 IndexStorageStrategy (org.opennms.netmgt.collection.support.IndexStorageStrategy)7 PersistAllSelectorStrategy (org.opennms.netmgt.collection.support.PersistAllSelectorStrategy)7 Test (org.junit.Test)5 Parameter (org.opennms.netmgt.config.datacollection.Parameter)5 HashMap (java.util.HashMap)3 GenericIndexResourceType (org.opennms.netmgt.collectd.GenericIndexResourceType)3 IfResourceType (org.opennms.netmgt.collectd.IfResourceType)3 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)3 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)3 GenericTypeResource (org.opennms.netmgt.collection.support.builder.GenericTypeResource)3 GenericIndexResource (org.opennms.netmgt.collectd.GenericIndexResource)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 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)2 NodeLevelResource (org.opennms.netmgt.collection.support.builder.NodeLevelResource)2