public void addDatasource(String sourcePath, String destPath, DsDef newDatasource) { if (Util.sameFilePath(sourcePath, destPath)) { throw new RrdException("Source and destination paths are the same"); } RrdDb rrdSource = new RrdDb(sourcePath); RrdDef rrdDef = rrdSource.getRrdDef(); rrdDef.setPath(destPath); rrdDef.addDatasource(newDatasource); RrdDb rrdDest = new RrdDb(rrdDef); rrdSource.copyStateTo(rrdDest); rrdSource.close(); rrdDest.close(); }
public void removeArchive(String sourcePath, String destPath, String consolFun, int steps) { if (Util.sameFilePath(sourcePath, destPath)) { throw new RrdException("Source and destination paths are the same"); } RrdDb rrdSource = new RrdDb(sourcePath); RrdDef rrdDef = rrdSource.getRrdDef(); rrdDef.setPath(destPath); rrdDef.removeArchive(consolFun, steps); RrdDb rrdDest = new RrdDb(rrdDef); rrdSource.copyStateTo(rrdDest); rrdSource.close(); rrdDest.close(); }
public void resizeArchive(String sourcePath, String destPath, String consolFun, int numSteps, int newRows) { if (Util.sameFilePath(sourcePath, destPath)) { throw new RrdException("Source and destination paths are the same"); } if (newRows < 2) { throw new RrdException("New arcihve size must be at least 2"); } RrdDb rrdSource = new RrdDb(sourcePath); RrdDef rrdDef = rrdSource.getRrdDef(); ArcDef arcDef = rrdDef.findArchive(consolFun, numSteps); if (arcDef.getRows() != newRows) { arcDef.setRows(newRows); rrdDef.setPath(destPath); RrdDb rrdDest = new RrdDb(rrdDef); rrdSource.copyStateTo(rrdDest); rrdDest.close(); } rrdSource.close(); }