use of org.opennms.netmgt.config.datacollection.DatacollectionConfig in project opennms by OpenNMS.
the class DataCollectionConfigFile method visit.
/**
* <p>visit</p>
*
* @param visitor a {@link org.opennms.netmgt.dao.jaxb.collector.DataCollectionVisitor} object.
*/
public void visit(DataCollectionVisitor visitor) {
DatacollectionConfig dataCollectionConfig = getDataCollectionConfig();
visitor.visitDataCollectionConfig(dataCollectionConfig);
for (Iterator<SnmpCollection> it = dataCollectionConfig.getSnmpCollections().iterator(); it.hasNext(); ) {
SnmpCollection snmpCollection = it.next();
doVisit(snmpCollection, visitor);
}
visitor.completeDataCollectionConfig(dataCollectionConfig);
}
use of org.opennms.netmgt.config.datacollection.DatacollectionConfig in project opennms by OpenNMS.
the class DefaultDataCollectionConfigDaoIT method executeSystemDefCount.
private void executeSystemDefCount(DefaultDataCollectionConfigDao dao, int expectedCount) {
DatacollectionConfig config = dao.getContainer().getObject();
int systemDefCount = 0;
for (SnmpCollection collection : config.getSnmpCollections()) {
systemDefCount += collection.getSystems().getSystemDefs().size();
}
Assert.assertEquals(expectedCount, systemDefCount);
}
use of org.opennms.netmgt.config.datacollection.DatacollectionConfig 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());
}
}
}
use of org.opennms.netmgt.config.datacollection.DatacollectionConfig in project opennms by OpenNMS.
the class DataCollectionConfigParserTest method testLoadSimpleWithExclusions.
@Test
public void testLoadSimpleWithExclusions() throws Exception {
// Create DatacollectionConfig
Resource resource = new InputStreamResource(this.getClass().getResourceAsStream("datacollection-config-excludes.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.assertNull(collection.getSystems());
Assert.assertNull(collection.getGroups());
// Execute Parser
executeParser(collection);
// Validate SNMP Collection
// Resource Types should live on a special collection
Assert.assertEquals(0, collection.getResourceTypes().size());
// 48 systemDef to exclude
Assert.assertEquals(41, collection.getSystems().getSystemDefs().size());
// 1 group to exclude (used only on Cisco PIX or Cisco AS)
Assert.assertEquals(27, collection.getGroups().getGroups().size());
}
Aggregations