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;
}
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());
}
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);
}
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));
}
Aggregations