local uci = luci.model.uci.cursor()
local sections = uci:get_all( "luci_statistics" )
- -- helper classes
- self.colors = luci.statistics.rrdtool.colors.Instance()
- self.tree = luci.statistics.datatree.Instance()
- self.i18n = luci.statistics.i18n.Instance( self )
-
-- options
opts.timespan = timespan or sections.rrdtool.default_timespan or 900
opts.rrasingle = opts.rrasingle or ( sections.collectd_rrdtool.RRASingle == "1" )
opts.rrdpath = opts.rrdpath:gsub("/$","")
opts.imgpath = opts.imgpath:gsub("/$","")
+ -- helper classes
+ self.colors = luci.statistics.rrdtool.colors.Instance()
+ self.tree = luci.statistics.datatree.Instance(opts.host)
+ self.i18n = luci.statistics.i18n.Instance( self )
+
-- rrdtool default args
self.args = {
"-a", "PNG",
if not ds or ds:len() == 0 then ds = "value" end
- _tif( _args, "DEF:%s_avg=%s:%s:AVERAGE", inst, rrd, ds )
+ _tif( _args, "DEF:%s_avg_raw=%s:%s:AVERAGE", inst, rrd, ds )
+ _tif( _args, "CDEF:%s_avg=%s_avg_raw,%s", inst, inst, source.transform_rpn )
if not self.opts.rrasingle then
- _tif( _args, "DEF:%s_min=%s:%s:MIN", inst, rrd, ds )
- _tif( _args, "DEF:%s_max=%s:%s:MAX", inst, rrd, ds )
+ _tif( _args, "DEF:%s_min_raw=%s:%s:MIN", inst, rrd, ds )
+ _tif( _args, "CDEF:%s_min=%s_min_raw,%s", inst, inst, source.transform_rpn )
+ _tif( _args, "DEF:%s_max_raw=%s:%s:MAX", inst, rrd, ds )
+ _tif( _args, "CDEF:%s_max=%s_max_raw,%s", inst, inst, source.transform_rpn )
end
_tif( _args, "CDEF:%s_nnl=%s_avg,UN,0,%s_avg,IF", inst, inst, inst )
-- is first source in stack or overlay source: source_stk = source_nnl
if not prev or source.overlay then
- -- create cdef statement
+ -- create cdef statement for cumulative stack (no NaNs) and also
+ -- for display (preserving NaN where no points should be displayed)
_tif( _args, "CDEF:%s_stk=%s_nnl", source.sname, source.sname )
+ _tif( _args, "CDEF:%s_plot=%s_avg", source.sname, source.sname )
-- is subsequent source without overlay: source_stk = source_nnl + previous_stk
else
-- create cdef statement
_tif( _args, "CDEF:%s_stk=%s_nnl,%s_stk,+", source.sname, source.sname, prev )
+ _tif( _args, "CDEF:%s_plot=%s_avg,%s_stk,+", source.sname, source.sname, prev )
end
-- create multiply by minus one cdef if flip is enabled
if source.flip then
-- create cdef statement: source_stk = source_stk * -1
- _tif( _args, "CDEF:%s_neg=%s_stk,-1,*", source.sname, source.sname )
+ _tif( _args, "CDEF:%s_neg=%s_plot,-1,*", source.sname, source.sname )
-- push to negative stack if overlay is disabled
if not source.overlay then
-- derive area background color from line color
area_color = self.colors:to_string( self.colors:faded( area_color ) )
- -- choose source_stk or source_neg variable depending on flip state
+ -- choose source_plot or source_neg variable depending on flip state
if source.flip then
var = "neg"
else
- var = "stk"
+ var = "plot"
end
-- create legend
flip = dopts.flip or false,
total = dopts.total or false,
overlay = dopts.overlay or false,
+ transform_rpn = dopts.transform_rpn or "0,+",
noarea = dopts.noarea or false,
title = dopts.title or nil,
ds = dsource,