double getMeanValue(Range range) throws IOException { assert range.getPeriod() == null; try { final DataProcessor dproc = processData(range); return dproc.getAggregate("average", ConsolFuns.CF_AVERAGE); } catch (final RrdException e) { throw createIOException(e); } }
/** * Returns aggregated value for a set of values calculated by applying an RPN expression to the * fetched data. For example, if you have two datasources named <code>x</code> and <code>y</code> * in this FetchData and you want to calculate MAX value of <code>(x+y)/2</code> use something like: * <p> * <code>getRpnAggregate("x,y,+,2,/", "MAX");</code> * * @param rpnExpression RRDTool-like RPN expression * @param consolFun Consolidation function (MIN, MAX, LAST, FIRST, AVERAGE or TOTAL) * @return Aggregated value * @throws RrdException Thrown if invalid RPN expression is supplied */ public double getRpnAggregate(String rpnExpression, String consolFun) throws RrdException { DataProcessor dataProcessor = createDataProcessor(rpnExpression); return dataProcessor.getAggregate(RPN_SOURCE_NAME, consolFun); }
/** * Returns single aggregated value from the fetched data for a single datasource. * * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. * Valid consolidation functions are "MIN", "MAX", "LAST", "FIRST", "AVERAGE" and "TOTAL" * (these string constants are conveniently defined in the {@link ConsolFuns} class) * @return MIN, MAX, LAST, FIRST, AVERAGE or TOTAL value calculated from the fetched data * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. */ public double getAggregate(String dsName, String consolFun) throws RrdException { DataProcessor dp = createDataProcessor(null); return dp.getAggregate(dsName, consolFun); }
void resolveText(DataProcessor dproc, ValueScaler valueScaler) throws RrdException { super.resolveText(dproc, valueScaler); if (resolvedText != null) { double value = dproc.getAggregate(srcName, consolFun); Matcher matcher = UNIT_PATTERN.matcher(resolvedText); if (matcher.find()) { // unit specified ValueScaler.Scaled scaled = valueScaler.scale(value, matcher.group(2).equals("s")); resolvedText = resolvedText.substring(0, matcher.start()) + matcher.group(1) + scaled.unit + resolvedText.substring(matcher.end()); value = scaled.value; } resolvedText = Util.sprintf(resolvedText, value); trimIfGlue(); } } }
/** * Returns aggregated value for a set of values calculated by applying an RPN expression to the * fetched data. For example, if you have two datasources named <code>x</code> and <code>y</code> * in this FetchData and you want to calculate MAX value of <code>(x+y)/2<code> use something like: <p> * <code>getRpnAggregate("x,y,+,2,/", "MAX");</code><p> * * @param rpnExpression RRDTool-like RPN expression * @param consolFun Consolidation function (MIN, MAX, LAST, FIRST, AVERAGE or TOTAL) * @return Aggregated value * @throws RrdException Thrown if invalid RPN expression is supplied */ public double getRpnAggregate(String rpnExpression, String consolFun) throws RrdException { DataProcessor dataProcessor = createDataProcessor(rpnExpression); return dataProcessor.getAggregate(RPN_SOURCE_NAME, consolFun); }
/** * Returns single aggregated value from the fetched data for a single datasource. * * @param dsName Datasource name * @param consolFun Consolidation function to be applied to fetched datasource values. * Valid consolidation functions are "MIN", "MAX", "LAST", "FIRST", "AVERAGE" and "TOTAL" * (these string constants are conveniently defined in the {@link ConsolFuns} class) * @return MIN, MAX, LAST, FIRST, AVERAGE or TOTAL value calculated from the fetched data * for the given datasource name * @throws RrdException Thrown if the given datasource name cannot be found in fetched data. */ public double getAggregate(String dsName, String consolFun) throws RrdException { DataProcessor dp = createDataProcessor(null); return dp.getAggregate(dsName, consolFun); }
void resolveText(DataProcessor dproc, ValueScaler valueScaler) throws RrdException { super.resolveText(dproc, valueScaler); if (resolvedText != null) { double value = dproc.getAggregate(srcName, consolFun); Matcher matcher = UNIT_PATTERN.matcher(resolvedText); if (matcher.find()) { // unit specified ValueScaler.Scaled scaled = valueScaler.scale(value, matcher.group(2).equals("s")); resolvedText = resolvedText.substring(0, matcher.start()) + matcher.group(1) + scaled.unit + resolvedText.substring(matcher.end()); value = scaled.value; } resolvedText = Util.sprintf(resolvedText, value); trimIfGlue(); } } }
double getMeanValue(Range range) throws IOException { assert range.getPeriod() == null; try { final DataProcessor dproc = processData(range); return dproc.getAggregate("average", ConsolFuns.CF_AVERAGE); } catch (final RrdException e) { throw createIOException(e); } }