luci-app-statisctis: only include lua modules in rrd statistics into local scope
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
8302e7995e
commit
c593a210b2
3 changed files with 19 additions and 22 deletions
|
@ -3,15 +3,14 @@
|
||||||
|
|
||||||
module("luci.statistics.i18n", package.seeall)
|
module("luci.statistics.i18n", package.seeall)
|
||||||
|
|
||||||
require("luci.util")
|
local util = require("luci.util")
|
||||||
require("luci.i18n")
|
local i18n = require("luci.i18n")
|
||||||
|
|
||||||
|
|
||||||
Instance = luci.util.class()
|
Instance = util.class()
|
||||||
|
|
||||||
|
|
||||||
function Instance.__init__( self, graph )
|
function Instance.__init__( self, graph )
|
||||||
self.i18n = luci.i18n
|
self.i18n = i18n
|
||||||
self.graph = graph
|
self.graph = graph
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,30 +3,28 @@
|
||||||
|
|
||||||
module("luci.statistics.rrdtool", package.seeall)
|
module("luci.statistics.rrdtool", package.seeall)
|
||||||
|
|
||||||
require("luci.statistics.datatree")
|
local tree = require("luci.statistics.datatree")
|
||||||
require("luci.statistics.rrdtool.colors")
|
local colors = require("luci.statistics.rrdtool.colors")
|
||||||
require("luci.statistics.i18n")
|
local i18n = require("luci.statistics.i18n")
|
||||||
require("luci.model.uci")
|
local uci = require("luci.model.uci").cursor()
|
||||||
require("luci.util")
|
local util = require("luci.util")
|
||||||
require("luci.sys")
|
local sys = require("luci.sys")
|
||||||
|
local fs = require("nixio.fs")
|
||||||
local fs = require "nixio.fs"
|
|
||||||
|
|
||||||
|
|
||||||
Graph = luci.util.class()
|
Graph = util.class()
|
||||||
|
|
||||||
function Graph.__init__( self, timespan, opts )
|
function Graph.__init__( self, timespan, opts )
|
||||||
|
|
||||||
opts = opts or { }
|
opts = opts or { }
|
||||||
|
|
||||||
local uci = luci.model.uci.cursor()
|
|
||||||
local sections = uci:get_all( "luci_statistics" )
|
local sections = uci:get_all( "luci_statistics" )
|
||||||
|
|
||||||
-- options
|
-- options
|
||||||
opts.timespan = timespan or sections.rrdtool.default_timespan or 900
|
opts.timespan = timespan or sections.rrdtool.default_timespan or 900
|
||||||
opts.rrasingle = opts.rrasingle or ( sections.collectd_rrdtool.RRASingle == "1" )
|
opts.rrasingle = opts.rrasingle or ( sections.collectd_rrdtool.RRASingle == "1" )
|
||||||
opts.rramax = opts.rramax or ( sections.collectd_rrdtool.RRAMax == "1" )
|
opts.rramax = opts.rramax or ( sections.collectd_rrdtool.RRAMax == "1" )
|
||||||
opts.host = opts.host or sections.collectd.Hostname or luci.sys.hostname()
|
opts.host = opts.host or sections.collectd.Hostname or sys.hostname()
|
||||||
opts.width = opts.width or sections.rrdtool.image_width or 400
|
opts.width = opts.width or sections.rrdtool.image_width or 400
|
||||||
opts.rrdpath = opts.rrdpath or sections.collectd_rrdtool.DataDir or "/tmp/rrd"
|
opts.rrdpath = opts.rrdpath or sections.collectd_rrdtool.DataDir or "/tmp/rrd"
|
||||||
opts.imgpath = opts.imgpath or sections.rrdtool.image_path or "/tmp/rrdimg"
|
opts.imgpath = opts.imgpath or sections.rrdtool.image_path or "/tmp/rrdimg"
|
||||||
|
@ -34,9 +32,9 @@ function Graph.__init__( self, timespan, opts )
|
||||||
opts.imgpath = opts.imgpath:gsub("/$","")
|
opts.imgpath = opts.imgpath:gsub("/$","")
|
||||||
|
|
||||||
-- helper classes
|
-- helper classes
|
||||||
self.colors = luci.statistics.rrdtool.colors.Instance()
|
self.colors = colors.Instance()
|
||||||
self.tree = luci.statistics.datatree.Instance(opts.host)
|
self.tree = tree.Instance(opts.host)
|
||||||
self.i18n = luci.statistics.i18n.Instance( self )
|
self.i18n = i18n.Instance( self )
|
||||||
|
|
||||||
-- rrdtool default args
|
-- rrdtool default args
|
||||||
self.args = {
|
self.args = {
|
||||||
|
@ -102,7 +100,7 @@ function Graph._rrdtool( self, def, rrd )
|
||||||
opt = opt:gsub( "{file}", rrd )
|
opt = opt:gsub( "{file}", rrd )
|
||||||
end
|
end
|
||||||
|
|
||||||
cmdline[#cmdline+1] = luci.util.shellquote(opt)
|
cmdline[#cmdline+1] = util.shellquote(opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- execute rrdtool
|
-- execute rrdtool
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
module("luci.statistics.rrdtool.colors", package.seeall)
|
module("luci.statistics.rrdtool.colors", package.seeall)
|
||||||
|
|
||||||
require("luci.util")
|
local util = require("luci.util")
|
||||||
|
|
||||||
|
|
||||||
Instance = luci.util.class()
|
Instance = util.class()
|
||||||
|
|
||||||
function Instance.from_string( self, s )
|
function Instance.from_string( self, s )
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue