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();
}
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());
}
}
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);
}
}
Aggregations