Search in sources :

Example 6 with RRDv1

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

the class RrdConvertUtilsIT method testConvertAdvRrdIntoJrb1.

/**
 * Test convert Advanced RRD into JRB (1).
 *
 * @throws Exception the exception
 */
@Test(expected = IllegalArgumentException.class)
public void testConvertAdvRrdIntoJrb1() throws Exception {
    RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump-compute-ds.xml"));
    RRDv1 jrb = RrdConvertUtils.convert(rrd);
    Assert.assertNull(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 7 with RRDv1

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

the class RrdConvertUtilsIT method testConvertJrbIntoRrd.

/**
 * Test convert JRB into RRD.
 *
 * @throws Exception the exception
 */
@Test
public void testConvertJrbIntoRrd() throws Exception {
    RRDv1 jrb = RrdConvertUtils.dumpJrb(new File("src/test/resources/tempA.jrb"));
    RRDv3 rrd = RrdConvertUtils.convert(jrb);
    Assert.assertNotNull(rrd);
}
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 8 with RRDv1

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

the class SnmpInterfaceRrdMigratorOnlineTest method testUpgrade.

/**
 * Test upgrade.
 *
 * @throws Exception the exception
 */
@Test
public void testUpgrade() throws Exception {
    // Check Current JRBs
    RRDv1 rrd = RrdConvertUtils.dumpJrb(new File("target/home/rrd/1/eth0/ifInOctets.jrb"));
    Row r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381500900l);
    Assert.assertNotNull(r);
    Assert.assertEquals(new Double(-6.0), r.getValues().get(0));
    r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381512300l);
    Assert.assertNull(r);
    rrd = RrdConvertUtils.dumpJrb(new File("target/home/rrd/1/eth0-005056c00008/ifInOctets.jrb"));
    r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381500900l);
    Assert.assertNotNull(r);
    Assert.assertTrue(r.getValues().get(0).isNaN());
    r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381512300l);
    Assert.assertNotNull(r);
    Assert.assertEquals(new Double(12.0), r.getValues().get(0));
    // Perform Migration
    SnmpInterfaceRrdMigratorOnline obj = new SnmpInterfaceRrdMigratorOnline() {

        protected List<SnmpInterfaceUpgrade> getInterfacesToMerge() throws OnmsUpgradeException {
            List<SnmpInterfaceUpgrade> interfaces = new ArrayList<>();
            interfaces.add(new SnmpInterfaceUpgrade(1, null, null, "eth0", "eth0", "005056c00008", false));
            return interfaces;
        }
    };
    obj.preExecute();
    obj.execute();
    obj.postExecute();
    // Verify if the backups have been removed
    Assert.assertFalse(new File("target/home/rrd/1/eth0.zip").exists());
    Assert.assertFalse(new File("target/home/rrd/1/eth0-005056c00008.zip").exists());
    // Check Merged JRB
    rrd = RrdConvertUtils.dumpJrb(new File("target/home/rrd/1/eth0-005056c00008/ifInOctets.jrb"));
    r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381500900l);
    Assert.assertNotNull(r);
    Assert.assertEquals(new Double(-6.0), r.getValues().get(0));
    r = rrd.findRowByTimestamp(rrd.getRras().get(0), 1381512300l);
    Assert.assertNotNull(r);
    Assert.assertEquals(new Double(12.0), r.getValues().get(0));
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) ArrayList(java.util.ArrayList) Row(org.opennms.netmgt.rrd.model.Row) File(java.io.File) Test(org.junit.Test)

Example 9 with RRDv1

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

the class SnmpInterfaceRrdMigratorOnline method mergeJrb.

/**
 * Merge JRBs.
 *
 * @param source the source JRB
 * @param dest the destination JRB
 * @throws Exception the exception
 */
protected void mergeJrb(File source, File dest) throws Exception {
    log("  merging JRB %s into %s\n", source, dest);
    RRDv1 rrdSrc = RrdConvertUtils.dumpJrb(source);
    RRDv1 rrdDst = RrdConvertUtils.dumpJrb(dest);
    if (rrdSrc == null || rrdDst == null) {
        log("  Warning: can't load JRBs (ingoring merge).\n");
        return;
    }
    rrdDst.merge(rrdSrc);
    final File outputFile = new File(dest.getCanonicalPath() + ".merged");
    RrdConvertUtils.restoreJrb(rrdDst, outputFile);
    if (dest.exists()) {
        FileUtils.deleteQuietly(dest);
    }
    FileUtils.moveFile(outputFile, dest);
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) File(java.io.File)

Example 10 with RRDv1

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

the class RrdConvertUtils method convertFromRrdToJrobin.

/**
 * Convert from RRDtool to JRobin.
 *
 * @param sourceRrdFile the source RRDtool file
 * @param targetJrobinFile the target JRobin file
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws RrdException the RRD exception
 */
public static void convertFromRrdToJrobin(File sourceRrdFile, File targetJrobinFile) throws IOException, RrdException {
    RRDv3 rrd = dumpRrd(sourceRrdFile);
    RRDv1 jrb = convert(rrd);
    restoreJrb(jrb, targetJrobinFile);
}
Also used : RRDv1(org.opennms.netmgt.rrd.model.v1.RRDv1) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3)

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