Search in sources :

Example 1 with ArcDef

use of org.jrobin.core.ArcDef in project opennms by OpenNMS.

the class JRobinConverterTest method initializeRrd.

private void initializeRrd(final File fileName, final String[] dsNames, final String[] archives) throws RrdException, IOException {
    final RrdDef rrdDef = new RrdDef(fileName.getAbsolutePath());
    rrdDef.setStartTime(0);
    final DsDef[] dsDefs = new DsDef[dsNames.length];
    for (int i = 0; i < dsNames.length; i++) {
        dsDefs[i] = new DsDef(dsNames[i], "COUNTER", 600, 0, Double.NaN);
    }
    rrdDef.addDatasource(dsDefs);
    final ArcDef[] arcDefs = new ArcDef[archives.length];
    for (int i = 0; i < archives.length; i++) {
        String[] entry = archives[i].split(":");
        Integer steps = Integer.valueOf(entry[0]);
        Integer rows = Integer.valueOf(entry[1]);
        arcDefs[i] = new ArcDef("AVERAGE", 0.5D, steps, rows);
    }
    rrdDef.addArchive(arcDefs);
    final RrdDb db = new RrdDb(rrdDef);
    db.close();
}
Also used : RrdDef(org.jrobin.core.RrdDef) DsDef(org.jrobin.core.DsDef) RrdDb(org.jrobin.core.RrdDb) ArcDef(org.jrobin.core.ArcDef)

Example 2 with ArcDef

use of org.jrobin.core.ArcDef in project jmxtrans by jmxtrans.

the class RRDToolWriter method rrdToolCreateDatabase.

/**
	 * Calls out to the rrdtool binary with the 'create' command.
	 */
protected void rrdToolCreateDatabase(RrdDef def) throws Exception {
    List<String> commands = new ArrayList<>();
    commands.add(this.binaryPath + "/rrdtool");
    commands.add("create");
    commands.add(this.outputFile.getCanonicalPath());
    commands.add("-s");
    commands.add(String.valueOf(def.getStep()));
    for (DsDef dsdef : def.getDsDefs()) {
        commands.add(getDsDefStr(dsdef));
    }
    for (ArcDef adef : def.getArcDefs()) {
        commands.add(getRraStr(adef));
    }
    ProcessBuilder pb = new ProcessBuilder(commands);
    Process process = pb.start();
    try {
        checkErrorStream(process);
    } finally {
        IOUtils.closeQuietly(process.getInputStream());
        IOUtils.closeQuietly(process.getOutputStream());
        IOUtils.closeQuietly(process.getErrorStream());
    }
}
Also used : DsDef(org.jrobin.core.DsDef) ArrayList(java.util.ArrayList) ArcDef(org.jrobin.core.ArcDef)

Example 3 with ArcDef

use of org.jrobin.core.ArcDef in project opennms by OpenNMS.

the class JRobinConverter method getRras.

public List<String> getRras(final File rrdFile) throws ConverterException {
    try {
        final List<String> rras = new ArrayList<String>();
        final RrdDb db = new RrdDb(rrdFile.getAbsolutePath(), true);
        for (final ArcDef def : db.getRrdDef().getArcDefs()) {
            rras.add(def.dump());
        }
        return rras;
    } catch (final Exception e) {
        LogUtils.debugf(JRobinConverter.class, e, "error reading file %s", rrdFile);
        throw new ConverterException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) RrdDb(org.jrobin.core.RrdDb) ArcDef(org.jrobin.core.ArcDef) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException) RrdException(org.jrobin.core.RrdException)

Aggregations

ArcDef (org.jrobin.core.ArcDef)3 ArrayList (java.util.ArrayList)2 DsDef (org.jrobin.core.DsDef)2 RrdDb (org.jrobin.core.RrdDb)2 IOException (java.io.IOException)1 ParseException (org.apache.commons.cli.ParseException)1 RrdDef (org.jrobin.core.RrdDef)1 RrdException (org.jrobin.core.RrdException)1