use of org.opennms.netmgt.collection.support.builder.NodeLevelResource in project opennms by OpenNMS.
the class NodeLevelResourceDTO method toResource.
public NodeLevelResource toResource() {
final NodeLevelResource resource = new NodeLevelResource(nodeId, path);
resource.setTimestamp(timestamp);
return resource;
}
use of org.opennms.netmgt.collection.support.builder.NodeLevelResource in project opennms by OpenNMS.
the class ThresholdingVisitorIT method runFileSystemDataTestWithCollectionSetBuilder.
private void runFileSystemDataTestWithCollectionSetBuilder(ThresholdingVisitor visitor, int resourceId, String fs, long value, long max) throws Exception {
SnmpCollectionAgent agent = createCollectionAgent();
NodeLevelResource nodeResource = new NodeLevelResource(agent.getNodeId());
// Creating Generic ResourceType
org.opennms.netmgt.config.datacollection.ResourceType indexResourceType = createIndexResourceType(agent, "hrStorageIndex");
GenericTypeResource genericResource = new GenericTypeResource(nodeResource, indexResourceType, Integer.toString(resourceId));
// Creating strings.properties file
ResourcePath path = ResourcePath.get("snmp", "1", "hrStorageIndex", Integer.toString(resourceId));
m_resourceStorageDao.setStringAttribute(path, "hrStorageType", ".1.3.6.1.2.1.25.2.1.4");
m_resourceStorageDao.setStringAttribute(path, "hrStorageDescr", fs);
// Build the collection set
CollectionSet collectionSet = new CollectionSetBuilder(agent).withNumericAttribute(genericResource, "hd-usage", "hrStorageUsed", value, AttributeType.GAUGE).withNumericAttribute(genericResource, "hd-usage", "hrStorageSize", max, AttributeType.GAUGE).withNumericAttribute(genericResource, "hd-usage", "hrStorageAllocUnits", 1, AttributeType.GAUGE).build();
// Run Visitor
collectionSet.visit(visitor);
EasyMock.verify(agent);
}
use of org.opennms.netmgt.collection.support.builder.NodeLevelResource 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