Search in sources :

Example 11 with DatacollectionGroup

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

the class DataCollectionConfigMigrator17Offline method getDataCollectionGroup.

/**
     * Gets the data collection group.
     *
     * @param configFile the configuration file
     * @return the data collection group
     */
private DatacollectionGroup getDataCollectionGroup(File configFile) {
    if (dataCollectionGroupMap.get(configFile) == null) {
        log("Parsing datacollection-group %s\n", configFile.getAbsolutePath());
        DatacollectionGroup grp = JaxbUtils.unmarshal(DatacollectionGroup.class, configFile);
        dataCollectionGroupMap.put(configFile, grp);
    }
    return dataCollectionGroupMap.get(configFile);
}
Also used : DatacollectionGroup(org.opennms.netmgt.config.datacollection.DatacollectionGroup)

Example 12 with DatacollectionGroup

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

the class MibCompilerPanel method generateDataCollection.

/**
     * Generate data collection.
     *
     * @param logger the logger
     * @param fileName the file name
     */
private void generateDataCollection(final Logger logger, final String fileName) {
    if (parseMib(logger, new File(MIBS_COMPILED_DIR, fileName))) {
        final DatacollectionGroup dcGroup = mibParser.getDataCollection();
        if (dcGroup == null) {
            Notification.show("The MIB couldn't be processed for data collection because: " + mibParser.getFormattedErrors(), Notification.Type.ERROR_MESSAGE);
        } else {
            if (dcGroup.getGroups().size() > 0) {
                try {
                    final String dataFileName = fileName.replaceFirst("\\..*$", ".xml");
                    final DataCollectionWindow w = new DataCollectionWindow(mibParser, dataCollectionDao, dataFileName, dcGroup, logger);
                    getUI().addWindow(w);
                } catch (Throwable t) {
                    Notification.show(t.getMessage(), Notification.Type.ERROR_MESSAGE);
                }
            } else {
                Notification.show("The MIB doesn't contain any metric for data collection.", Notification.Type.WARNING_MESSAGE);
            }
        }
    }
}
Also used : DataCollectionWindow(org.opennms.features.vaadin.datacollection.DataCollectionWindow) File(java.io.File) DatacollectionGroup(org.opennms.netmgt.config.datacollection.DatacollectionGroup)

Example 13 with DatacollectionGroup

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

the class DataCollectionConfigParserTest method validateParser.

private static void validateParser(DataCollectionConfigParser parser) {
    Map<String, DatacollectionGroup> groupMap = parser.getExternalGroupMap();
    int currentResourceTypes = 0;
    int currentSystemDefs = 0;
    int currentMibGroups = 0;
    for (DatacollectionGroup group : groupMap.values()) {
        currentResourceTypes += group.getResourceTypes().size();
    }
    for (DatacollectionGroup group : groupMap.values()) {
        currentSystemDefs += group.getSystemDefs().size();
    }
    for (DatacollectionGroup group : groupMap.values()) {
        currentMibGroups += group.getGroups().size();
    }
    Assert.assertEquals(resourceTypesCount, currentResourceTypes);
    Assert.assertEquals(systemDefCount, currentSystemDefs);
    Assert.assertEquals(groupsCount, currentMibGroups);
}
Also used : DatacollectionGroup(org.opennms.netmgt.config.datacollection.DatacollectionGroup)

Aggregations

DatacollectionGroup (org.opennms.netmgt.config.datacollection.DatacollectionGroup)13 File (java.io.File)6 Group (org.opennms.netmgt.config.datacollection.Group)4 MibObj (org.opennms.netmgt.config.datacollection.MibObj)3 ResourceType (org.opennms.netmgt.config.datacollection.ResourceType)3 Test (org.junit.Test)2 IncludeCollection (org.opennms.netmgt.config.datacollection.IncludeCollection)2 FileSystemResource (org.springframework.core.io.FileSystemResource)2 FileWriter (java.io.FileWriter)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1