use of org.opennms.netmgt.config.datacollection.SystemDef in project opennms by OpenNMS.
the class DataCollectionConfigFile method doVisit.
private void doVisit(Systems systems, DataCollectionVisitor visitor) {
for (Iterator<SystemDef> it = systems.getSystemDefs().iterator(); it.hasNext(); ) {
SystemDef systemDef = it.next();
doVisit(systemDef, visitor);
}
}
use of org.opennms.netmgt.config.datacollection.SystemDef in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDaoIT method compareContent.
private void compareContent(DatacollectionConfig refObj, DatacollectionConfig newObj) {
Set<String> resourceTypes = new HashSet<>();
Set<String> systemDefs = new HashSet<>();
Set<String> groups = new HashSet<>();
for (SnmpCollection collection : refObj.getSnmpCollections()) {
for (SystemDef sd : collection.getSystems().getSystemDefs()) {
systemDefs.add(sd.getName());
for (String group : sd.getCollect().getIncludeGroups()) {
groups.add(group);
}
}
for (Group g : collection.getGroups().getGroups()) {
if (groups.contains(g.getName())) {
for (MibObj mo : g.getMibObjs()) {
String i = mo.getInstance();
if (!i.matches("\\d+") && !i.equals("ifIndex"))
resourceTypes.add(mo.getInstance());
}
}
}
}
for (SnmpCollection collection : newObj.getSnmpCollections()) {
for (Group g : collection.getGroups().getGroups()) {
for (MibObj mo : g.getMibObjs()) {
String i = mo.getInstance();
if (!i.matches("\\d+") && !i.equals("ifIndex"))
resourceTypes.remove(mo.getInstance());
}
}
for (SystemDef sd : collection.getSystems().getSystemDefs()) {
systemDefs.remove(sd.getName());
for (String group : sd.getCollect().getIncludeGroups()) {
groups.remove(group);
}
}
}
if (systemDefs.size() > 0) {
Assert.fail("There are un-configured system definitions on the new datacollection: " + systemDefs);
}
if (groups.size() > 0) {
Assert.fail("There are un-configured groups on the new datacollection: " + groups);
}
if (resourceTypes.size() > 0) {
Assert.fail("There are un-configured resourceTypes on the new datacollection: " + resourceTypes);
}
}
use of org.opennms.netmgt.config.datacollection.SystemDef 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;
}
use of org.opennms.netmgt.config.datacollection.SystemDef in project opennms by OpenNMS.
the class SystemDefForm method createBasicSystemDef.
/**
* Creates the basic system definition.
*
* @return the system definition
*/
public SystemDef createBasicSystemDef() {
SystemDef sysDef = new SystemDef();
sysDef.setName("New System Definition");
sysDef.setSysoidMask(".1.3.6.1.4.1.");
sysDef.setCollect(new Collect());
return sysDef;
}
use of org.opennms.netmgt.config.datacollection.SystemDef in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testPrecedence.
@Test
public void testPrecedence() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-hybrid-precedence.xml"));
DatacollectionConfig config = JaxbUtils.unmarshal(DatacollectionConfig.class, resource, false);
// Validate default datacollection content
SnmpCollection collection = config.getSnmpCollections().get(0);
Assert.assertEquals(1, collection.getIncludeCollections().size());
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(1, collection.getSystems().getSystemDefs().size());
Assert.assertEquals(1, collection.getGroups().getGroups().size());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
Assert.assertEquals(71, collection.getSystems().getSystemDefs().size());
Assert.assertEquals(14, collection.getGroups().getGroups().size());
// This is a way to "override" the content of a specific datacollection-group.
for (Group group : collection.getGroups().getGroups()) {
if (group.getName().equals("cisco-frame-relay")) {
Assert.assertEquals(4, group.getMibObjs().size());
}
}
for (SystemDef systemDef : collection.getSystems().getSystemDefs()) {
if (systemDef.getName().equals("Cisco Routers")) {
Assert.assertEquals(3, systemDef.getCollect().getIncludeGroups().size());
}
}
}
Aggregations