Search in sources :

Example 6 with NodeInfo

use of org.opennms.netmgt.collectd.NodeInfo 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);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) ResourcePath(org.opennms.netmgt.model.ResourcePath) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) HashMap(java.util.HashMap) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection) Test(org.junit.Test)

Example 7 with NodeInfo

use of org.opennms.netmgt.collectd.NodeInfo 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);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) Test(org.junit.Test)

Example 8 with NodeInfo

use of org.opennms.netmgt.collectd.NodeInfo 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);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource)

Example 9 with NodeInfo

use of org.opennms.netmgt.collectd.NodeInfo 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);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) HashMap(java.util.HashMap) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) MockDataCollectionConfig(org.opennms.netmgt.mock.MockDataCollectionConfig) ServiceParameters(org.opennms.netmgt.collection.api.ServiceParameters) OnmsSnmpCollection(org.opennms.netmgt.collectd.OnmsSnmpCollection)

Aggregations

NodeInfo (org.opennms.netmgt.collectd.NodeInfo)9 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)9 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)8 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)8 Test (org.junit.Test)6 SnmpAttributeType (org.opennms.netmgt.collectd.SnmpAttributeType)5 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)5 MibObject (org.opennms.netmgt.config.datacollection.MibObject)5 NumericAttributeType (org.opennms.netmgt.collectd.NumericAttributeType)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)3 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)3 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)3 SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)1 StringAttributeType (org.opennms.netmgt.collectd.StringAttributeType)1 ResourcePath (org.opennms.netmgt.model.ResourcePath)1