Search in sources :

Example 21 with SnmpCollectionResource

use of org.opennms.netmgt.collectd.SnmpCollectionResource 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 22 with SnmpCollectionResource

use of org.opennms.netmgt.collectd.SnmpCollectionResource in project opennms by OpenNMS.

the class ThresholdingVisitorIT method testBug3227.

/*
     * This test uses this files from src/test/resources:
     * - threshd-configuration.xml
     * - test-thresholds-bug3227.xml
     * 
     * There is no Frame Relay related thresholds definitions on test-thresholds-bug3227.xml.
     * When visit resources, getEntityMap from ThresholdingSet must be null.
     * Updated to reflect the fact that counter are treated as rates.
     */
@Test
public void testBug3227() throws Exception {
    initFactories("/threshd-configuration.xml", "/test-thresholds-bug3227.xml");
    ThresholdingVisitor visitor = createVisitor();
    SnmpCollectionAgent agent = createCollectionAgent();
    GenericIndexResourceType resourceType = createGenericIndexResourceType(agent, "frCircuitIfIndex");
    // Creating Resource
    SnmpInstId inst = new SnmpInstId(100);
    SnmpCollectionResource resource = new GenericIndexResource(resourceType, "frCircuitIfIndex", inst);
    addAttributeToCollectionResource(resource, resourceType, "frReceivedOctets", "counter", "frCircuitIfIndex", 1000);
    addAttributeToCollectionResource(resource, resourceType, "frSentOctets", "counter", "frCircuitIfIndex", 1000);
    /*
         * Run Visitor
         * I must receive 2 special info events because getEntityMap should be called 2 times.
         * One for each attribute and one for each resource.
         * Original code will throw a NullPointerException after call getEntityMap.
         * Original code expects WARNs, but this message is now an INFO.
         */
    resource.visit(visitor);
}
Also used : SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) SnmpInstId(org.opennms.netmgt.snmp.SnmpInstId) GenericIndexResource(org.opennms.netmgt.collectd.GenericIndexResource) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) GenericIndexResourceType(org.opennms.netmgt.collectd.GenericIndexResourceType) Test(org.junit.Test)

Aggregations

SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)22 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)22 Test (org.junit.Test)17 HashMap (java.util.HashMap)10 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)10 Date (java.util.Date)9 SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)9 NodeInfo (org.opennms.netmgt.collectd.NodeInfo)8 CollectionAttribute (org.opennms.netmgt.collection.api.CollectionAttribute)8 IfResourceType (org.opennms.netmgt.collectd.IfResourceType)6 SnmpAttributeType (org.opennms.netmgt.collectd.SnmpAttributeType)6 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)6 MibObject (org.opennms.netmgt.config.datacollection.MibObject)6 GenericIndexResource (org.opennms.netmgt.collectd.GenericIndexResource)5 GenericIndexResourceType (org.opennms.netmgt.collectd.GenericIndexResourceType)5 NumericAttributeType (org.opennms.netmgt.collectd.NumericAttributeType)5 OnmsSnmpCollection (org.opennms.netmgt.collectd.OnmsSnmpCollection)5 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)5 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)5 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)5