use of org.opennms.netmgt.collectd.NodeResourceType in project opennms by OpenNMS.
the class ThresholdingVisitorIT method testThresholdsFiltersOnNodeResource.
/*
* This test uses this files from src/test/resources:
* - threshd-configuration.xml
* - test-thresholds-5.xml
*/
@Test
public void testThresholdsFiltersOnNodeResource() throws Exception {
initFactories("/threshd-configuration.xml", "/test-thresholds-5.xml");
ThresholdingVisitor visitor = createVisitor();
// Adding Expected Thresholds
addHighThresholdEvent(1, 30, 25, 50, "/home", "node", "(hda1_hrStorageUsed/hda1_hrStorageSize)*100", null, null);
addHighThresholdEvent(1, 50, 45, 60, "/opt", "node", "(hda2_hrStorageUsed/hda2_hrStorageSize)*100", null, null);
// Creating Node ResourceType
SnmpCollectionAgent agent = createCollectionAgent();
MockDataCollectionConfig dataCollectionConfig = new MockDataCollectionConfig();
OnmsSnmpCollection collection = new OnmsSnmpCollection(agent, new ServiceParameters(new HashMap<String, Object>()), dataCollectionConfig, m_locationAwareSnmpClient);
NodeResourceType resourceType = new NodeResourceType(agent, collection);
// Creating strings.properties file
ResourcePath path = ResourcePath.get("snmp", "1");
m_resourceStorageDao.setStringAttribute(path, "hda1_hrStorageDescr", "/home");
m_resourceStorageDao.setStringAttribute(path, "hda2_hrStorageDescr", "/opt");
m_resourceStorageDao.setStringAttribute(path, "hda3_hrStorageDescr", "/usr");
// Creating Resource
SnmpCollectionResource resource = new NodeInfo(resourceType, agent);
addAttributeToCollectionResource(resource, resourceType, "hda1_hrStorageUsed", "gauge", "node", 50);
addAttributeToCollectionResource(resource, resourceType, "hda1_hrStorageSize", "gauge", "node", 100);
addAttributeToCollectionResource(resource, resourceType, "hda2_hrStorageUsed", "gauge", "node", 60);
addAttributeToCollectionResource(resource, resourceType, "hda2_hrStorageSize", "gauge", "node", 100);
addAttributeToCollectionResource(resource, resourceType, "hda3_hrStorageUsed", "gauge", "node", 70);
addAttributeToCollectionResource(resource, resourceType, "hda3_hrStorageSize", "gauge", "node", 100);
// Run Visitor and Verify Events
resource.visit(visitor);
EasyMock.verify(agent);
verifyEvents(0);
}
use of org.opennms.netmgt.collectd.NodeResourceType in project opennms by OpenNMS.
the class ThresholdingVisitorIT method testNMS5115.
/*
* This test uses this files from src/test/resources:
* - threshd-configuration.xml
* - test-thresholds-NMS5115.xml
*
* The idea is to be able to use any numeric metric inside the resource filters. NMS-5115 is a valid use case for this.
*/
@Test
public void testNMS5115() throws Exception {
initFactories("/threshd-configuration.xml", "/test-thresholds-NMS5115.xml");
addEvent(EventConstants.LOW_THRESHOLD_EVENT_UEI, "127.0.0.1", "SNMP", 1, null, null, 5.0, "node", "node", "memAvailSwap / memTotalSwap * 100.0", null, null, m_anticipator, m_anticipatedEvents);
ThresholdingVisitor visitor = createVisitor();
SnmpCollectionAgent agent = createCollectionAgent();
NodeResourceType resourceType = createNodeResourceType(agent);
SnmpCollectionResource resource = new NodeInfo(resourceType, agent);
addAttributeToCollectionResource(resource, resourceType, "memAvailSwap", "gauge", "0", 5);
addAttributeToCollectionResource(resource, resourceType, "memTotalSwap", "gauge", "0", 100);
resource.visit(visitor);
EasyMock.verify(agent);
verifyEvents(0);
}
use of org.opennms.netmgt.collectd.NodeResourceType in project opennms by OpenNMS.
the class ThresholdingVisitorIT method runGaugeDataTest.
private void runGaugeDataTest(ThresholdingVisitor visitor, long value) {
SnmpCollectionAgent agent = createCollectionAgent();
NodeResourceType resourceType = createNodeResourceType(agent);
SnmpCollectionResource resource = new NodeInfo(resourceType, agent);
addAttributeToCollectionResource(resource, resourceType, "freeMem", "gauge", "0", value);
resource.visit(visitor);
EasyMock.verify(agent);
}
use of org.opennms.netmgt.collectd.NodeResourceType 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.NodeResourceType 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