Search in sources :

Example 6 with MibObject

use of org.opennms.netmgt.config.datacollection.MibObject in project opennms by OpenNMS.

the class DefaultDataCollectionConfigDao method getMibObjectList.

@Override
public List<MibObject> getMibObjectList(final String cName, final String aSysoid, final String anAddress, final int ifType) {
    LOG.debug("getMibObjectList: collection: {} sysoid: {} address: {} ifType: {}", cName, aSysoid, anAddress, ifType);
    if (aSysoid == null) {
        LOG.debug("getMibObjectList: aSysoid parameter is NULL...");
        return new ArrayList<MibObject>();
    }
    // Retrieve the appropriate Collection object
    final SnmpCollection collection = getSnmpCollection(getContainer(), cName);
    if (collection == null) {
        return Collections.emptyList();
    }
    final Systems systems = collection.getSystems();
    if (systems == null) {
        return Collections.emptyList();
    }
    // First build a list of SystemDef objects which "match" the passed
    // sysoid and IP address parameters. The SystemDef object must match
    // on both the sysoid AND the IP address.
    //
    // SYSOID MATCH
    //
    // A SystemDef object's sysoid value may be a complete system object
    // identifier or it may be a mask (a partial sysoid).
    //
    // If the sysoid is not a mask, the 'aSysoid' string must equal the
    // sysoid value exactly in order to match.
    //
    // If the sysoid is a mask, the 'aSysoid' string need only start with
    // the sysoid mask value in order to match
    //
    // For example, a sysoid mask of ".1.3.6.1.4.1.11." would match any
    // Hewlett-Packard product which had this sysoid prefix (which should
    // include all of them).
    //
    // IPADDRESS MATCH
    //
    // In order to match on IP Address one of the following must be true:
    // 
    // The SystemDef's IP address list (ipList) must contain the 'anAddress'
    // parm (must be an exact match)
    //
    // OR
    //
    // The 'anAddress' parm must have the same prefix as one of the
    // SystemDef's IP address mask list (maskList) entries.
    //
    // NOTE: A SystemDef object which contains an empty IP list and
    // an empty Mask list matches ALL IP addresses (default is INCLUDE).
    final List<SystemDef> systemList = new ArrayList<SystemDef>();
    for (final SystemDef system : systems.getSystemDefs()) {
        if (systemDefMatches(system, aSysoid, anAddress)) {
            LOG.debug("getMibObjectList: MATCH!! adding system '{}'", system.getName());
            systemList.add(system);
        }
    }
    // Next build list of Mib objects to collect from the list of matching SystemDefs
    final List<MibObject> mibObjectList = new ArrayList<MibObject>();
    for (final SystemDef system : systemList) {
        // Next process each of the SystemDef's groups
        for (final String grpName : system.getCollect().getIncludeGroups()) {
            processGroupName(cName, grpName, ifType, mibObjectList);
        }
    }
    return mibObjectList;
}
Also used : SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) ArrayList(java.util.ArrayList) SystemDef(org.opennms.netmgt.config.datacollection.SystemDef) MibObject(org.opennms.netmgt.config.datacollection.MibObject) Systems(org.opennms.netmgt.config.datacollection.Systems)

Example 7 with MibObject

use of org.opennms.netmgt.config.datacollection.MibObject in project opennms by OpenNMS.

the class ThresholdingVisitorIT method testResourceCounterData.

/*
     * This test uses this files from src/test/resources:
     * - threshd-configuration.xml
     * - test-thresholds.xml
     * 
     * Updated to reflect the fact that counter are treated as rates (counter wrap is not checked here anymore).
     */
@Test
public void testResourceCounterData() throws Exception {
    initFactories("/threshd-configuration.xml", "/test-thresholds-counters.xml");
    ThresholdingVisitor visitor = createVisitor();
    SnmpCollectionAgent agent = createCollectionAgent();
    NodeResourceType resourceType = createNodeResourceType(agent);
    MibObject mibObject = createMibObject("counter", "myCounter", "0");
    SnmpAttributeType attributeType = new NumericAttributeType(resourceType, "default", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));
    // Add Events
    addHighThresholdEvent(1, 10, 5, 15, "node", "node", "myCounter", null, null);
    addHighRearmEvent(1, 10, 5, 2, "node", "node", "myCounter", null, null);
    long baseDate = new Date().getTime();
    // Step 0: Visit a CollectionSet with a timestamp, so that the thresholder knows how when the collection was held 
    // Normally visiting the CollectionSet would end up visiting the resources, but we're fudging that for the test
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate));
    // Collect Step 1 : Initialize counter cache.
    SnmpCollectionResource resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(1000));
    resource.visit(visitor);
    // Collect Step 2 : Trigger. (last-current)/step => (5500-1000)/300=15
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 300000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(5500));
    resource.visit(visitor);
    // Collect Step 3 : Rearm. (last-current)/step => (6100-5500)/300=2
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 600000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(6100));
    resource.visit(visitor);
    EasyMock.verify(agent);
    verifyEvents(0);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) NumericAttributeType(org.opennms.netmgt.collectd.NumericAttributeType) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) AttributeGroupType(org.opennms.netmgt.collection.api.AttributeGroupType) MibObject(org.opennms.netmgt.config.datacollection.MibObject) SnmpAttributeType(org.opennms.netmgt.collectd.SnmpAttributeType) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) Date(java.util.Date) Test(org.junit.Test)

Example 8 with MibObject

use of org.opennms.netmgt.config.datacollection.MibObject in project opennms by OpenNMS.

the class ThresholdingVisitorIT method testZeroIntervalResourceCounterData.

@Test
public void testZeroIntervalResourceCounterData() throws Exception {
    initFactories("/threshd-configuration.xml", "/test-thresholds-counters.xml");
    ThresholdingVisitor visitor = createVisitor();
    SnmpCollectionAgent agent = createCollectionAgent();
    NodeResourceType resourceType = createNodeResourceType(agent);
    MibObject mibObject = createMibObject("counter", "myCounter", "0");
    SnmpAttributeType attributeType = new NumericAttributeType(resourceType, "default", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));
    // Add Events
    addHighThresholdEvent(1, 10, 5, 15, "node", "node", "myCounter", null, null);
    addHighRearmEvent(1, 10, 5, 2, "node", "node", "myCounter", null, null);
    long baseDate = new Date().getTime();
    // Step 0: Visit a CollectionSet with a timestamp, so that the thresholder knows how when the collection was held 
    // Normally visiting the CollectionSet would end up visiting the resources, but we're fudging that for the test
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate));
    // Collect Step 1 : Initialize counter cache.
    SnmpCollectionResource resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(1000));
    resource.visit(visitor);
    // Collect Step 1.5 : Send a new data point with the same timestamp as before and a
    // different value. This should not trigger a threshold violation because the time
    // interval is zero. It should also not reset the cached value for the attribute
    // because the time interval is zero.
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(5500));
    resource.visit(visitor);
    // Collect Step 2 : Trigger. (last-current)/step => (5500-1000)/300=15
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 300000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(5500));
    resource.visit(visitor);
    // Collect Step 3 : Rearm. (last-current)/step => (6100-5500)/300=2
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 600000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(6100));
    resource.visit(visitor);
    EasyMock.verify(agent);
    verifyEvents(0);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) NumericAttributeType(org.opennms.netmgt.collectd.NumericAttributeType) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) AttributeGroupType(org.opennms.netmgt.collection.api.AttributeGroupType) MibObject(org.opennms.netmgt.config.datacollection.MibObject) SnmpAttributeType(org.opennms.netmgt.collectd.SnmpAttributeType) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) Date(java.util.Date) Test(org.junit.Test)

Example 9 with MibObject

use of org.opennms.netmgt.config.datacollection.MibObject in project opennms by OpenNMS.

the class ThresholdingVisitorIT method createMibObject.

private static MibObject createMibObject(String type, String alias, String instance) {
    MibObject mibObject = new MibObject();
    mibObject.setOid(".1.1.1.1");
    mibObject.setAlias(alias);
    mibObject.setType(type);
    mibObject.setInstance(instance);
    mibObject.setMaxval(null);
    mibObject.setMinval(null);
    return mibObject;
}
Also used : MibObject(org.opennms.netmgt.config.datacollection.MibObject)

Example 10 with MibObject

use of org.opennms.netmgt.config.datacollection.MibObject in project opennms by OpenNMS.

the class ThresholdingVisitorIT method testBug3193.

/*
     * This test uses this files from src/test/resources:
     * - threshd-configuration.xml
     * - test-thresholds-bug3193.xml
     * 
     * Updated to reflect the fact that counter are treated as rates.
     */
@Test
public void testBug3193() throws Exception {
    initFactories("/threshd-configuration.xml", "/test-thresholds-bug3193.xml");
    ThresholdingVisitor visitor = createVisitor();
    SnmpCollectionAgent agent = createCollectionAgent();
    NodeResourceType resourceType = createNodeResourceType(agent);
    MibObject mibObject = createMibObject("counter", "myCounter", "0");
    SnmpAttributeType attributeType = new NumericAttributeType(resourceType, "default", mibObject, new AttributeGroupType("mibGroup", AttributeGroupType.IF_TYPE_IGNORE));
    // Add Events
    addHighThresholdEvent(1, 100, 90, 110, "node", "node", "myCounter", null, null);
    addHighThresholdEvent(1, 70, 60, 80, "node", "node", "myCounter - 30", null, null);
    addHighRearmEvent(1, 100, 90, 40, "node", "node", "myCounter", null, null);
    addHighRearmEvent(1, 70, 60, 10, "node", "node", "myCounter - 30", null, null);
    long baseDate = new Date().getTime();
    // Collect Step 1 : First Data: Last should be NaN
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate));
    SnmpCollectionResource resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(2000));
    resource.visit(visitor);
    // Collect Step 2 : First Value: (last-current)/step => (20000-2000)/300=60
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 300000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(20000));
    resource.visit(visitor);
    // Collect Step 3 : Second Value: (last-current)/step => (53000-20000)/300=110 => Trigger
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 600000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(53000));
    resource.visit(visitor);
    // Collect Step 3 : Third Value (last-current)/step => (65000-53000)/300=40 => Rearm
    visitor.visitCollectionSet(createAnonymousCollectionSet(baseDate + 900000));
    resource = new NodeInfo(resourceType, agent);
    resource.setAttributeValue(attributeType, SnmpUtils.getValueFactory().getCounter32(65000));
    resource.visit(visitor);
    EasyMock.verify(agent);
    verifyEvents(0);
}
Also used : NodeResourceType(org.opennms.netmgt.collectd.NodeResourceType) NumericAttributeType(org.opennms.netmgt.collectd.NumericAttributeType) SnmpCollectionAgent(org.opennms.netmgt.collectd.SnmpCollectionAgent) NodeInfo(org.opennms.netmgt.collectd.NodeInfo) AttributeGroupType(org.opennms.netmgt.collection.api.AttributeGroupType) MibObject(org.opennms.netmgt.config.datacollection.MibObject) SnmpAttributeType(org.opennms.netmgt.collectd.SnmpAttributeType) SnmpCollectionResource(org.opennms.netmgt.collectd.SnmpCollectionResource) Date(java.util.Date) Test(org.junit.Test)

Aggregations

MibObject (org.opennms.netmgt.config.datacollection.MibObject)25 AttributeGroupType (org.opennms.netmgt.collection.api.AttributeGroupType)16 Test (org.junit.Test)9 SnmpAttributeType (org.opennms.netmgt.collectd.SnmpAttributeType)9 NumericAttributeType (org.opennms.netmgt.collectd.NumericAttributeType)8 HashMap (java.util.HashMap)6 SnmpCollectionAgent (org.opennms.netmgt.collectd.SnmpCollectionAgent)6 SnmpCollectionResource (org.opennms.netmgt.collectd.SnmpCollectionResource)6 ServiceParameters (org.opennms.netmgt.collection.api.ServiceParameters)6 NodeInfo (org.opennms.netmgt.collectd.NodeInfo)5 NodeResourceType (org.opennms.netmgt.collectd.NodeResourceType)5 MockDataCollectionConfig (org.opennms.netmgt.mock.MockDataCollectionConfig)5 SnmpInstId (org.opennms.netmgt.snmp.SnmpInstId)5 Date (java.util.Date)4 RrdRepository (org.opennms.netmgt.rrd.RrdRepository)4 SnmpResult (org.opennms.netmgt.snmp.SnmpResult)4 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)4 SnmpAttribute (org.opennms.netmgt.collectd.SnmpAttribute)3 CollectionResource (org.opennms.netmgt.collection.api.CollectionResource)3 RrdPersistOperationBuilder (org.opennms.netmgt.collection.persistence.rrd.RrdPersistOperationBuilder)3