protected boolean validateDataSource(RrdDb aDb, String name) { try { return aDb.getDatasource(name) != null; } catch (IOException e) { throw new EtmException(e); } }
} else { if (rrd.containsDs(dsName)) { datasources = new Datasource[]{rrd.getDatasource(dsName)}; } else { throw new IllegalArgumentException("Could not find datasource [" + dsName + "] in file " + sourcePath);
/** * Returns Datasource object corresponding to the given datasource name. * * @param dsName Datasource name * @return Datasource object corresponding to the give datasource name or null if not found. * @throws java.io.IOException Thrown in case of I/O error */ public Datasource getDatasource(String dsName) throws IOException { try { return getDatasource(getDsIndex(dsName)); } catch (IllegalArgumentException e) { return null; } }
/** * Returns Datasource object corresponding to the given datasource name. * * @param dsName Datasource name * @return Datasource object corresponding to the give datasource name or null * if not found. * @throws IOException Thrown in case of I/O error */ public Datasource getDatasource(String dsName) throws IOException { try { return getDatasource(getDsIndex(dsName)); } catch (IllegalArgumentException e) { return null; } }
static int getMatchingDatasourceIndex(RrdDb rrd1, int dsIndex, RrdDb rrd2) throws IOException { String dsName = rrd1.getDatasource(dsIndex).getName(); try { return rrd2.getDsIndex(dsName); } catch (IllegalArgumentException e) { return -1; } }
static int getMatchingDatasourceIndex(RrdDb rrd1, int dsIndex, RrdDb rrd2) throws IOException { String dsName = rrd1.getDatasource(dsIndex).getName(); try { return rrd2.getDsIndex(dsName); } catch (IllegalArgumentException e) { return -1; } }
/** * Sets datasource heartbeat to a new value. * * @param sourcePath Path to exisiting RRD file (will be updated) * @param dsIndex Index of the datasource in the specified RRD file * @param newHeartbeat New datasource heartbeat * @throws IOException Thrown in case of I/O error */ public static void setDsHeartbeat(String sourcePath, int dsIndex, long newHeartbeat) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { Datasource ds = rrd.getDatasource(dsIndex); ds.setHeartbeat(newHeartbeat); } finally { rrd.close(); } }
/** * Sets datasource heartbeat to a new value. * * @param sourcePath Path to exisiting RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newHeartbeat New datasource heartbeat * @throws IOException Thrown in case of I/O error */ public static void setDsHeartbeat(String sourcePath, String datasourceName, long newHeartbeat) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { Datasource ds = rrd.getDatasource(datasourceName); ds.setHeartbeat(newHeartbeat); } finally { rrd.close(); } }
public Map<String, Number> getLastValues() { Map<String, Number> retValues = new HashMap<String, Number>(); RrdDb rrdDb = null; try { rrdDb = factory.getRrd(getPath()); String[] dsNames = rrdDb.getDsNames(); for(int i = 0; i < dsNames.length; i++) { retValues.put(dsNames[i], rrdDb.getDatasource(i).getLastValue()); } } catch (Exception e) { log(Level.ERROR, e, "Unable to get last values: %s", e.getMessage()); } finally { if(rrdDb != null) factory.releaseRrd(rrdDb); } return retValues; }
/** * Updates valid value range for the given datasource. * * @param sourcePath Path to exisiting RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newMinValue New min value for the datasource * @param newMaxValue New max value for the datasource * @param filterArchivedValues set to <code>true</code> if archived values outside * of the specified min/max range should be replaced with NaNs. * @throws IOException Thrown in case of I/O error */ public static void setDsMinMaxValue(String sourcePath, String datasourceName, double newMinValue, double newMaxValue, boolean filterArchivedValues) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { Datasource ds = rrd.getDatasource(datasourceName); ds.setMinMaxValue(newMinValue, newMaxValue, filterArchivedValues); } finally { rrd.close(); } }
/** * Sets datasource max value to a new value. * * @param sourcePath Path to exisiting RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newMaxValue New max value for the datasource * @param filterArchivedValues set to <code>true</code> if archived values greater than * <code>newMaxValue</code> should be set to NaN; set to false, otherwise. * @throws IOException Thrown in case of I/O error */ public static void setDsMaxValue(String sourcePath, String datasourceName, double newMaxValue, boolean filterArchivedValues) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { Datasource ds = rrd.getDatasource(datasourceName); ds.setMaxValue(newMaxValue, filterArchivedValues); } finally { rrd.close(); } }
/** * Sets datasource min value to a new value * * @param sourcePath Path to exisiting RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newMinValue New min value for the datasource * @param filterArchivedValues set to <code>true</code> if archived values less than * <code>newMinValue</code> should be set to NaN; set to false, otherwise. * @throws IOException Thrown in case of I/O error */ public static void setDsMinValue(String sourcePath, String datasourceName, double newMinValue, boolean filterArchivedValues) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { Datasource ds = rrd.getDatasource(datasourceName); ds.setMinValue(newMinValue, filterArchivedValues); } finally { rrd.close(); } }
/** * Renames single datasource in the given RRD file. * * @param sourcePath Path to a RRD file * @param oldDsName Old datasource name * @param newDsName New datasource name * @throws IOException Thrown in case of I/O error */ public static void renameDatasource(String sourcePath, String oldDsName, String newDsName) throws IOException { RrdDb rrd = new RrdDb(sourcePath); try { if (rrd.containsDs(oldDsName)) { Datasource datasource = rrd.getDatasource(oldDsName); datasource.setDsName(newDsName); } else { throw new IllegalArgumentException("Could not find datasource [" + oldDsName + "] in file " + sourcePath); } } finally { rrd.close(); } }
/** * Renames single datasource in the given RRD file. * * @param sourcePath Path to a RRD file * @param oldDsName Old datasource name * @param newDsName New datasource name * @throws java.io.IOException Thrown in case of I/O error */ public static void renameDatasource(String sourcePath, String oldDsName, String newDsName) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { if (rrd.containsDs(oldDsName)) { Datasource datasource = rrd.getDatasource(oldDsName); datasource.setDsName(newDsName); } else { throw new IllegalArgumentException("Could not find datasource [" + oldDsName + "] in file " + sourcePath); } } }
/** * Sets datasource heartbeat to a new value. * * @param sourcePath Path to existing RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newHeartbeat New datasource heartbeat * @throws java.io.IOException Thrown in case of I/O error */ public static void setDsHeartbeat(String sourcePath, String datasourceName, long newHeartbeat) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { Datasource ds = rrd.getDatasource(datasourceName); ds.setHeartbeat(newHeartbeat); } }
/** * Sets datasource heartbeat to a new value. * * @param sourcePath Path to existing RRD file (will be updated) * @param dsIndex Index of the datasource in the specified RRD file * @param newHeartbeat New datasource heartbeat * @throws java.io.IOException Thrown in case of I/O error */ public static void setDsHeartbeat(String sourcePath, int dsIndex, long newHeartbeat) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { Datasource ds = rrd.getDatasource(dsIndex); ds.setHeartbeat(newHeartbeat); } }
/** * Sets datasource max value to a new value. * * @param sourcePath Path to existing RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newMaxValue New max value for the datasource * @param filterArchivedValues set to <code>true</code> if archived values greater than * <code>newMaxValue</code> should be set to NaN; set to false, otherwise. * @throws java.io.IOException Thrown in case of I/O error */ public static void setDsMaxValue(String sourcePath, String datasourceName, double newMaxValue, boolean filterArchivedValues) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { Datasource ds = rrd.getDatasource(datasourceName); ds.setMaxValue(newMaxValue, filterArchivedValues); } }
/** * Sets datasource min value to a new value * * @param sourcePath Path to existing RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newMinValue New min value for the datasource * @param filterArchivedValues set to <code>true</code> if archived values less than * <code>newMinValue</code> should be set to NaN; set to false, otherwise. * @throws java.io.IOException Thrown in case of I/O error */ public static void setDsMinValue(String sourcePath, String datasourceName, double newMinValue, boolean filterArchivedValues) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { Datasource ds = rrd.getDatasource(datasourceName); ds.setMinValue(newMinValue, filterArchivedValues); } }
/** * Updates valid value range for the given datasource. * * @param sourcePath Path to existing RRD file (will be updated) * @param datasourceName Name of the datasource in the specified RRD file * @param newMinValue New min value for the datasource * @param newMaxValue New max value for the datasource * @param filterArchivedValues set to <code>true</code> if archived values outside * of the specified min/max range should be replaced with NaNs. * @throws java.io.IOException Thrown in case of I/O error */ public static void setDsMinMaxValue(String sourcePath, String datasourceName, double newMinValue, double newMaxValue, boolean filterArchivedValues) throws IOException { try (RrdDb rrd = RrdDb.getBuilder().setPath(sourcePath).build()) { Datasource ds = rrd.getDatasource(datasourceName); ds.setMinMaxValue(newMinValue, newMaxValue, filterArchivedValues); } }
RrdDb rrd = new RrdDb(file.getAbsolutePath(), true); try { Datasource ds = rrd.getDatasource(dsIndex); values = new Object[]{ ds.getName(),