From: Hannu Nyman Date: Thu, 12 May 2016 07:26:59 +0000 (+0300) Subject: luci-app-statistics: option for max/avg data when not rrasingle X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=84083ce54d6d67569d82c26955627bb1f41a05ff;p=oweals%2Fluci.git luci-app-statistics: option for max/avg data when not rrasingle Introduce option that enables the user to select max values instead of averages for graphs if the user has disabled RRAsingle. The option defaults to average values, which have been the default in Luci statistics. Remove 'optional' from RRASingle, as it is a key option for statistics. Signed-off-by: Hannu Nyman (cherry picked from commit b213573682460dd395878c7369aba173f00bbb99) --- diff --git a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua index b3bdf874c..f31fb2093 100644 --- a/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua +++ b/applications/luci-app-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua @@ -47,10 +47,16 @@ heartbeat:depends( "enable", 1 ) rrasingle = s:option( Flag, "RRASingle", translate("Only create average RRAs"), translate("reduces rrd size") ) rrasingle.default = true -rrasingle.rmempty = true -rrasingle.optional = true rrasingle:depends( "enable", 1 ) +-- collectd_rrdtool.rramax (RRAMax) +rramax = s:option( Flag, "RRAMax", + translate("Show max values instead of averages"), + translate("Max values for a period can be used instead of averages when not using 'only average RRAs'") ) +rramax.default = false +rramax.rmempty = true +rramax:depends( "RRASingle", 0 ) + -- collectd_rrdtool.rratimespans (RRATimespan) rratimespans = s:option( Value, "RRATimespans", translate("Stored timespans"), translate("seconds; multiple separated by space") ) diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua index cd2395e11..4e00e7f1f 100644 --- a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua +++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua @@ -25,6 +25,7 @@ function Graph.__init__( self, timespan, opts ) -- options opts.timespan = timespan or sections.rrdtool.default_timespan or 900 opts.rrasingle = opts.rrasingle or ( sections.collectd_rrdtool.RRASingle == "1" ) + opts.rramax = opts.rramax or ( sections.collectd_rrdtool.RRAMax == "1" ) opts.host = opts.host or sections.collectd.Hostname or luci.sys.hostname() opts.width = opts.width or sections.rrdtool.image_width or 400 opts.rrdpath = opts.rrdpath or sections.collectd_rrdtool.DataDir or "/tmp/rrd" @@ -171,7 +172,7 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) -- is first source in stack or overlay source: source_stk = source_nnl if not prev or source.overlay then - if self.opts.rrasingle then + if self.opts.rrasingle or not self.opts.rramax then -- 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 ) @@ -185,7 +186,7 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index ) -- is subsequent source without overlay: source_stk = source_nnl + previous_stk else - if self.opts.rrasingle then + if self.opts.rrasingle or not self.opts.rramax then -- 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 )