Search in sources :

Example 1 with Systems

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

the class DefaultDataCollectionConfigDao method translateConfig.

@Override
protected DatacollectionConfig translateConfig(final DatacollectionConfig config) {
    final DataCollectionConfigParser parser = new DataCollectionConfigParser(getConfigDirectory());
    resourceTypes.clear();
    final Map<String, DatacollectionGroup> externalGroupMap = parser.getExternalGroupMap();
    // Create a special collection to hold all resource types, because they should be defined only once.
    final SnmpCollection resourceTypeCollection = new SnmpCollection();
    resourceTypeCollection.setName("__resource_type_collection");
    // Updating Configured Collections
    for (final SnmpCollection collection : config.getSnmpCollections()) {
        parser.parseCollection(collection);
        // Save local resource types
        for (final ResourceType rt : collection.getResourceTypes()) {
            resourceTypeCollection.addResourceType(rt);
            resourceTypes.put(rt.getName(), rt);
        }
        // Remove local resource types
        collection.setResourceTypes(new ArrayList<ResourceType>());
        // Save external Resource Types
        for (IncludeCollection include : collection.getIncludeCollections()) {
            if (include.getDataCollectionGroup() != null) {
                DatacollectionGroup group = externalGroupMap.get(include.getDataCollectionGroup());
                for (final ResourceType rt : group.getResourceTypes()) {
                    resourceTypeCollection.addResourceType(rt);
                    resourceTypes.put(rt.getName(), rt);
                }
            }
        }
    }
    resourceTypeCollection.setGroups(new Groups());
    resourceTypeCollection.setSystems(new Systems());
    config.insertSnmpCollection(resourceTypeCollection);
    dataCollectionGroups.clear();
    dataCollectionGroups.addAll(parser.getExternalGroupMap().keySet());
    validateResourceTypes(config.getSnmpCollections(), resourceTypes.keySet());
    return config;
}
Also used : SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) Groups(org.opennms.netmgt.config.datacollection.Groups) IncludeCollection(org.opennms.netmgt.config.datacollection.IncludeCollection) ResourceType(org.opennms.netmgt.config.datacollection.ResourceType) DatacollectionGroup(org.opennms.netmgt.config.datacollection.DatacollectionGroup) Systems(org.opennms.netmgt.config.datacollection.Systems)

Example 2 with Systems

use of org.opennms.netmgt.config.datacollection.Systems 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<>();
    }
    // 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<>();
    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<>();
    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 3 with Systems

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

the class DefaultDataCollectionConfigDao method getMibObjProperties.

@Override
public List<MibObjProperty> getMibObjProperties(final String cName, final String aSysoid, final String anAddress) {
    LOG.debug("getMibObjProperties: collection: {} sysoid: {} address: {}", cName, aSysoid, anAddress);
    if (aSysoid == null) {
        LOG.debug("getMibObjProperties: aSysoid parameter is NULL...");
        return new ArrayList<>();
    }
    final SnmpCollection collection = getSnmpCollection(getContainer(), cName);
    if (collection == null) {
        return Collections.emptyList();
    }
    final Systems systems = collection.getSystems();
    if (systems == null) {
        return Collections.emptyList();
    }
    final List<SystemDef> systemList = new ArrayList<>();
    for (final SystemDef system : systems.getSystemDefs()) {
        if (systemDefMatches(system, aSysoid, anAddress)) {
            systemList.add(system);
        }
    }
    final List<MibObjProperty> mibProperties = new ArrayList<>();
    for (final SystemDef system : systemList) {
        for (final String grpName : system.getCollect().getIncludeGroups()) {
            processGroupForProperties(cName, grpName, mibProperties);
        }
    }
    return mibProperties;
}
Also used : SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) MibObjProperty(org.opennms.netmgt.config.datacollection.MibObjProperty) ArrayList(java.util.ArrayList) SystemDef(org.opennms.netmgt.config.datacollection.SystemDef) Systems(org.opennms.netmgt.config.datacollection.Systems)

Aggregations

SnmpCollection (org.opennms.netmgt.config.datacollection.SnmpCollection)3 Systems (org.opennms.netmgt.config.datacollection.Systems)3 ArrayList (java.util.ArrayList)2 SystemDef (org.opennms.netmgt.config.datacollection.SystemDef)2 DatacollectionGroup (org.opennms.netmgt.config.datacollection.DatacollectionGroup)1 Groups (org.opennms.netmgt.config.datacollection.Groups)1 IncludeCollection (org.opennms.netmgt.config.datacollection.IncludeCollection)1 MibObjProperty (org.opennms.netmgt.config.datacollection.MibObjProperty)1 MibObject (org.opennms.netmgt.config.datacollection.MibObject)1 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)1