use of org.jrobin.core.DsDef 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();
}
use of org.jrobin.core.DsDef 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());
}
}