Search in sources :

Example 16 with RRDv1

use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.

the class RrdConvertUtilsIT method testJrobinParse.

/**
 * Test JRobin parse.
 *
 * @throws Exception the exception
 */
@Test
public void testJrobinParse() throws Exception {
    RRDv1 jrb = RrdConvertUtils.dumpJrb(new File("src/test/resources/tempA.jrb"));
    Assert.assertNotNull(jrb);
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) File(java.io.File) Test(org.junit.Test)

Example 17 with RRDv1

use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.

the class RrdConvertUtilsIT method testConvertRrdIntoJrb.

/**
 * Test convert RRD into JRB.
 *
 * @throws Exception the exception
 */
@Test
public void testConvertRrdIntoJrb() throws Exception {
    RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump.xml"));
    RRDv1 jrb = RrdConvertUtils.convert(rrd);
    Assert.assertNotNull(jrb);
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) File(java.io.File) Test(org.junit.Test)

Example 18 with RRDv1

use of org.opennms.netmgt.rrd.model.v1.RRDv1 in project opennms by OpenNMS.

the class JRobinConverter method consolidateRrdFile.

public void consolidateRrdFile(final File groupFile, final File outputFile) throws IOException, RrdException, ConverterException {
    /*
        final List<RrdDatabase> rrds = new ArrayList<>();
        rrds.add(new RrdDatabase(new RrdDb(groupFile, true)));
        for (final File individualFile : getMatchingGroupRrds(groupFile)) {
            final RrdDb individualRrd = new RrdDb(individualFile, true);
            rrds.add(new RrdDatabase(individualRrd));
        }
        final TimeSeriesDataSource dataSource = new AggregateTimeSeriesDataSource(rrds);

        final RrdDb outputRrd = new RrdDb(outputFile);
        final RrdDatabaseWriter writer = new RrdDatabaseWriter(outputRrd);

        final long endTime = dataSource.getEndTime();
        // 1 year
        final long startTime = endTime - ONE_YEAR_IN_SECONDS;
        for (long time = startTime; time <= endTime; time += dataSource.getNativeStep()) {
            final RrdEntry entry = dataSource.getDataAt(time);
            writer.write(entry);
        }
        dataSource.close();
        outputRrd.close();
        */
    final RRDv1 groupRrd = RrdConvertUtils.dumpJrb(groupFile);
    LogUtils.debugf(this, "consolidateRrdFile: multi-metric RRD with %d data sources", groupRrd.getDataSources().size());
    int i = 1;
    for (AbstractDS ds : groupRrd.getDataSources()) {
        LogUtils.debugf(this, "consolidateRrdFile: multi-metric data source %d: %s", i++, ds.getName());
    }
    final List<RRDv1> singleMetricFiles = new ArrayList<>();
    for (final File individualFile : getMatchingGroupRrds(groupFile)) {
        final RRDv1 singleRrd = RrdConvertUtils.dumpJrb(individualFile);
        LogUtils.debugf(this, "consolidateRrdFile: adding single-metric RRD for data source %s", singleRrd.getDataSource(0).getName());
        singleMetricFiles.add(singleRrd);
    }
    groupRrd.merge(singleMetricFiles);
    RrdConvertUtils.restoreJrb(groupRrd, outputFile);
}
Also used : AbstractDS(org.opennms.netmgt.rrd.model.AbstractDS) RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

RRDv1 (org.opennms.netmgt.rrd.model.v1.RRDv1)18 File (java.io.File)13 Test (org.junit.Test)11 RRDv3 (org.opennms.netmgt.rrd.model.v3.RRDv3)8 ArrayList (java.util.ArrayList)3 RRA (org.opennms.netmgt.rrd.model.v1.RRA)2 FileWriter (java.io.FileWriter)1 List (java.util.List)1 FileUtils (org.apache.commons.io.FileUtils)1 RrdDb (org.jrobin.core.RrdDb)1 Assert (org.junit.Assert)1 JaxbUtils (org.opennms.core.xml.JaxbUtils)1 AbstractDS (org.opennms.netmgt.rrd.model.AbstractDS)1 Row (org.opennms.netmgt.rrd.model.Row)1 CFType (org.opennms.netmgt.rrd.model.v1.CFType)1 DSType (org.opennms.netmgt.rrd.model.v1.DSType)1