* luci/app/statistics:
- build datatree from rrd directory structure, allows "virtual" plugins - flush index cache on statistics reload - whitespace cleanup in config generator
This commit is contained in:
parent
9f19574ae0
commit
0543ad6f4f
3 changed files with 34 additions and 19 deletions
|
@ -7,7 +7,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ local util = require("luci.util")
|
||||||
local sys = require("luci.sys")
|
local sys = require("luci.sys")
|
||||||
local fs = require("luci.fs")
|
local fs = require("luci.fs")
|
||||||
local uci = require("luci.model.uci").cursor()
|
local uci = require("luci.model.uci").cursor()
|
||||||
local sections = uci:get_all( "luci_statistics" )
|
local sections = uci:get_all("luci_statistics")
|
||||||
|
|
||||||
|
|
||||||
Instance = util.class()
|
Instance = util.class()
|
||||||
|
@ -59,13 +59,25 @@ function Instance._notzero( self, table )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Instance._scan( self )
|
function Instance._scan( self )
|
||||||
local dir = fs.dir( self._libdir )
|
local dirs = fs.dir( self:_mkpath() )
|
||||||
if not dir then
|
if not dirs then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
for i, plugin in ipairs( dir ) do
|
|
||||||
if plugin:match("%w+.so") then
|
-- for i, plugin in ipairs( dirs ) do
|
||||||
self._plugins[ plugin:gsub(".so", "") ] = { }
|
-- if plugin:match("%w+.so") then
|
||||||
|
-- self._plugins[ plugin:gsub("%.so$", "") ] = { }
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
|
for _, dir in ipairs(dirs) do
|
||||||
|
if dir ~= "." and dir ~= ".." and
|
||||||
|
fs.stat(self:_mkpath(dir)).type == "directory"
|
||||||
|
then
|
||||||
|
local plugin = dir:gsub("%-.+$", "")
|
||||||
|
if not self._plugins[plugin] then
|
||||||
|
self._plugins[plugin] = { }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ start() {
|
||||||
imagepath="$(uci get luci_statistics.rrdtool.image_path)"
|
imagepath="$(uci get luci_statistics.rrdtool.image_path)"
|
||||||
ln -s ${imagepath:-/tmp/rrdimg}/ /www/rrdimg
|
ln -s ${imagepath:-/tmp/rrdimg}/ /www/rrdimg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
### flush LuCI index cache
|
||||||
|
test -f /var/luci-indexcache && rm /var/luci-indexcache
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
@ -96,15 +96,15 @@ function config_exec( c )
|
||||||
|
|
||||||
cmd = sections[s].cmdline
|
cmd = sections[s].cmdline
|
||||||
|
|
||||||
if cmd then
|
if cmd then
|
||||||
cmd = cmd:gsub("^%s+", ""):gsub("%s+$", "")
|
cmd = cmd:gsub("^%s+", ""):gsub("%s+$", "")
|
||||||
user = sections[s].cmduser or "nobody"
|
user = sections[s].cmduser or "nobody"
|
||||||
group = sections[s].cmdgroup
|
group = sections[s].cmdgroup
|
||||||
|
|
||||||
str = str .. "\t" .. key .. ' "' ..
|
str = str .. "\t" .. key .. ' "' ..
|
||||||
user .. ( group and ":" .. group or "" ) .. '" "' ..
|
user .. ( group and ":" .. group or "" ) .. '" "' ..
|
||||||
cmd:gsub('%s+', '" "') .. '"\n'
|
cmd:gsub('%s+', '" "') .. '"\n'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -162,9 +162,9 @@ function config_network( c )
|
||||||
str = str .. "\t" .. key .. " " .. host .. "\n"
|
str = str .. "\t" .. key .. " " .. host .. "\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return str .. _string( c["TimeToLive"], "TimeToLive" )
|
return str .. _string( c["TimeToLive"], "TimeToLive" )
|
||||||
.. _string( c["CacheFlush"], "CacheFlush" )
|
.. _string( c["CacheFlush"], "CacheFlush" )
|
||||||
|
|
Loading…
Reference in a new issue