Search in sources :

Example 11 with DatacollectionConfig

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);
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection)

Example 12 with 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);
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection)

Example 13 with DatacollectionConfig

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());
        }
    }
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) Group(org.opennms.netmgt.config.datacollection.Group) DatacollectionGroup(org.opennms.netmgt.config.datacollection.DatacollectionGroup) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) FileSystemResource(org.springframework.core.io.FileSystemResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) SystemDef(org.opennms.netmgt.config.datacollection.SystemDef) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Example 14 with DatacollectionConfig

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());
}
Also used : DatacollectionConfig(org.opennms.netmgt.config.datacollection.DatacollectionConfig) SnmpCollection(org.opennms.netmgt.config.datacollection.SnmpCollection) FileSystemResource(org.springframework.core.io.FileSystemResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) InputStreamResource(org.springframework.core.io.InputStreamResource) Test(org.junit.Test)

Aggregations

DatacollectionConfig (org.opennms.netmgt.config.datacollection.DatacollectionConfig)14 Test (org.junit.Test)9 SnmpCollection (org.opennms.netmgt.config.datacollection.SnmpCollection)9 FileSystemResource (org.springframework.core.io.FileSystemResource)7 InputStreamResource (org.springframework.core.io.InputStreamResource)6 Resource (org.springframework.core.io.Resource)6 File (java.io.File)3 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 FileUtils (org.apache.commons.io.FileUtils)2 XmlTest (org.opennms.core.test.xml.XmlTest)2 JaxbUtils (org.opennms.core.xml.JaxbUtils)2 DatacollectionGroup (org.opennms.netmgt.config.datacollection.DatacollectionGroup)2 OnmsUpgradeException (org.opennms.upgrade.api.OnmsUpgradeException)2 CommitException (com.vaadin.data.fieldgroup.FieldGroup.CommitException)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1