Search in sources :

Example 6 with RRDv3

use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.

the class RRDv3IT method parseRrdWithAberrantBehaviorDetection.

/**
 * Parses the RRD with aberrant behavior detection.
 *
 * @throws Exception the exception
 */
@Test
public void parseRrdWithAberrantBehaviorDetection() throws Exception {
    RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, new File("src/test/resources/rrd-dump-aberrant-behavior-detection.xml"));
    Assert.assertNotNull(rrd);
}
Also used : RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) File(java.io.File) Test(org.junit.Test)

Example 7 with RRDv3

use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.

the class RRDv3IT method testSamplesMultipleRRAs1.

/**
 * Test samples for multiple RRAs (1)
 *
 * @throws Exception the exception
 */
@Test
public void testSamplesMultipleRRAs1() throws Exception {
    File source = new File("src/test/resources/sample-counter-rras.xml");
    RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, source);
    Assert.assertNotNull(rrd);
    NavigableMap<Long, List<Double>> samples = rrd.generateSamples(rrd.getRras().get(1));
    Assert.assertFalse(samples.isEmpty());
    Assert.assertEquals(rrd.getRras().get(1).getRows().size(), samples.size());
}
Also used : RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Test(org.junit.Test)

Example 8 with RRDv3

use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.

the class RRDv3IT method testSamplesSingleRRA.

/**
 * Test samples for a single RRA
 *
 * @throws Exception the exception
 */
@Test
public void testSamplesSingleRRA() throws Exception {
    File source = new File("src/test/resources/sample-counter.xml");
    RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, source);
    Assert.assertNotNull(rrd);
    NavigableMap<Long, List<Double>> samples = rrd.generateSamples(rrd.getRras().get(0));
    Assert.assertFalse(samples.isEmpty());
    long ts = 1441748400L;
    Double v1 = 600.0;
    Double v2 = 2.0;
    Assert.assertEquals(rrd.getRras().get(0).getRows().size(), samples.size());
    for (Map.Entry<Long, List<Double>> s : samples.entrySet()) {
        System.out.println(s);
        Assert.assertEquals(2, s.getValue().size());
        Assert.assertEquals(ts, (long) s.getKey());
        Assert.assertEquals(v1, s.getValue().get(0));
        Assert.assertEquals(v2, s.getValue().get(1));
        ts += 300L;
        v1 += 300.0 * v2;
        v2 += 1.0;
    }
}
Also used : RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) NavigableMap(java.util.NavigableMap) Map(java.util.Map) SortedMap(java.util.SortedMap) Test(org.junit.Test)

Example 9 with RRDv3

use of org.opennms.netmgt.rrd.model.v3.RRDv3 in project opennms by OpenNMS.

the class RRDv3IT method testSamplesMultipleRRAs2.

/**
 * Test samples for multiple RRAs (2)
 *
 * @throws Exception the exception
 */
@Test
public void testSamplesMultipleRRAs2() throws Exception {
    File source = new File("src/test/resources/sample-counter-rras.xml");
    RRDv3 rrd = JaxbUtils.unmarshal(RRDv3.class, source);
    Assert.assertNotNull(rrd);
    SortedMap<Long, List<Double>> samples = rrd.generateSamples();
    Assert.assertFalse(samples.isEmpty());
    int size = rrd.getRras().stream().mapToInt(r -> r.getRows().size()).sum();
    // There are 3 timestamps that exist in both RRAs and the last one is incomplete
    Assert.assertEquals(size - 3 - 1, samples.size());
}
Also used : FileWriter(java.io.FileWriter) RRA(org.opennms.netmgt.rrd.model.v3.RRA) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) CFType(org.opennms.netmgt.rrd.model.v3.CFType) DSType(org.opennms.netmgt.rrd.model.v3.DSType) NavigableMap(java.util.NavigableMap) AbstractRRD(org.opennms.netmgt.rrd.model.AbstractRRD) File(java.io.File) ArrayList(java.util.ArrayList) List(java.util.List) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) Map(java.util.Map) JaxbUtils(org.opennms.core.xml.JaxbUtils) Assert(org.junit.Assert) Row(org.opennms.netmgt.rrd.model.Row) SortedMap(java.util.SortedMap) RRDv3(org.opennms.netmgt.rrd.model.v3.RRDv3) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Test(org.junit.Test)

Example 10 with RRDv3

use of org.opennms.netmgt.rrd.model.v3.RRDv3 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)

Aggregations

RRDv3 (org.opennms.netmgt.rrd.model.v3.RRDv3)21 File (java.io.File)15 Test (org.junit.Test)14 RRDv1 (org.opennms.netmgt.rrd.model.v1.RRDv1)8 ArrayList (java.util.ArrayList)5 Row (org.opennms.netmgt.rrd.model.Row)4 List (java.util.List)3 RRA (org.opennms.netmgt.rrd.model.v3.RRA)3 FileWriter (java.io.FileWriter)2 Map (java.util.Map)2 NavigableMap (java.util.NavigableMap)2 SortedMap (java.util.SortedMap)2 AbstractRRD (org.opennms.netmgt.rrd.model.AbstractRRD)2 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 SAXSource (javax.xml.transform.sax.SAXSource)1 FileUtils (org.apache.commons.io.FileUtils)1 RrdException (org.jrobin.core.RrdException)1