use of org.opennms.netmgt.collectd.OnmsSnmpCollection 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.collectd.OnmsSnmpCollection in project opennms by OpenNMS.
the class CollectionResourceWrapperIT method createNodeResource.
private SnmpCollectionResource createNodeResource(SnmpCollectionAgent agent) {
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
NodeResourceType resourceType = new NodeResourceType(agent, collection);
return new NodeInfo(resourceType, agent);
}
use of org.opennms.netmgt.collectd.OnmsSnmpCollection in project opennms by OpenNMS.
the class ThresholdingVisitorIT method createInterfaceResourceType.
private IfResourceType createInterfaceResourceType(SnmpCollectionAgent agent) {
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
return new IfResourceType(agent, collection);
}
use of org.opennms.netmgt.collectd.OnmsSnmpCollection in project opennms by OpenNMS.
the class ThresholdingVisitorIT method createNodeResourceType.
private NodeResourceType createNodeResourceType(SnmpCollectionAgent agent) {
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
return new NodeResourceType(agent, collection);
}
Aggregations