luci-0.9: merge r4932 and r4933
This commit is contained in:
parent
d9b28ec7a4
commit
8b01581917
2 changed files with 43 additions and 8 deletions
|
@ -17,7 +17,7 @@ module("luci.statistics.datatree", package.seeall)
|
||||||
|
|
||||||
local util = require("luci.util")
|
local util = require("luci.util")
|
||||||
local sys = require("luci.sys")
|
local sys = require("luci.sys")
|
||||||
local fs = require("luci.fs")
|
local fs = require("nixio.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")
|
||||||
|
|
||||||
|
@ -50,6 +50,19 @@ function Instance._mkpath( self, plugin, pinstance )
|
||||||
return dir
|
return dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Instance._ls( self, ... )
|
||||||
|
local ditr = fs.dir(self:_mkpath(...))
|
||||||
|
if ditr then
|
||||||
|
local dirs = { }
|
||||||
|
while true do
|
||||||
|
local d = ditr()
|
||||||
|
if not d then break end
|
||||||
|
dirs[#dirs+1] = d
|
||||||
|
end
|
||||||
|
return dirs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Instance._notzero( self, table )
|
function Instance._notzero( self, table )
|
||||||
for k in pairs(table) do
|
for k in pairs(table) do
|
||||||
return true
|
return true
|
||||||
|
@ -59,7 +72,7 @@ function Instance._notzero( self, table )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Instance._scan( self )
|
function Instance._scan( self )
|
||||||
local dirs = fs.dir( self:_mkpath() )
|
local dirs = self:_ls()
|
||||||
if not dirs then
|
if not dirs then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -72,7 +85,7 @@ function Instance._scan( self )
|
||||||
|
|
||||||
for _, dir in ipairs(dirs) do
|
for _, dir in ipairs(dirs) do
|
||||||
if dir ~= "." and dir ~= ".." and
|
if dir ~= "." and dir ~= ".." and
|
||||||
fs.stat(self:_mkpath(dir)).type == "directory"
|
fs.stat(self:_mkpath(dir)).type == "dir"
|
||||||
then
|
then
|
||||||
local plugin = dir:gsub("%-.+$", "")
|
local plugin = dir:gsub("%-.+$", "")
|
||||||
if not self._plugins[plugin] then
|
if not self._plugins[plugin] then
|
||||||
|
@ -83,7 +96,7 @@ function Instance._scan( self )
|
||||||
|
|
||||||
for plugin, instances in pairs( self._plugins ) do
|
for plugin, instances in pairs( self._plugins ) do
|
||||||
|
|
||||||
local dirs = fs.dir( self:_mkpath() )
|
local dirs = self:_ls()
|
||||||
|
|
||||||
if type(dirs) == "table" then
|
if type(dirs) == "table" then
|
||||||
for i, dir in ipairs(dirs) do
|
for i, dir in ipairs(dirs) do
|
||||||
|
@ -101,7 +114,7 @@ function Instance._scan( self )
|
||||||
|
|
||||||
for instance, data_instances in pairs( instances ) do
|
for instance, data_instances in pairs( instances ) do
|
||||||
|
|
||||||
dirs = fs.dir( self:_mkpath( plugin, instance ) )
|
dirs = self:_ls(plugin, instance)
|
||||||
|
|
||||||
if type(dirs) == "table" then
|
if type(dirs) == "table" then
|
||||||
for i, file in ipairs(dirs) do
|
for i, file in ipairs(dirs) do
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
#!/bin/sh /etc/rc.common
|
#!/bin/sh /etc/rc.common
|
||||||
START=79
|
START=79
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
### prepare publisher
|
||||||
|
if ! uci get lucid.rrdimg >/dev/null 2>/dev/null; then
|
||||||
|
uci batch <<-EOF
|
||||||
|
set lucid.rrdimg=DirectoryPublisher
|
||||||
|
set lucid.rrdimg.name='Statistics Images'
|
||||||
|
set lucid.rrdimg.physical=/tmp/rrdimg
|
||||||
|
set lucid.rrdimg.virtual=/rrdimg
|
||||||
|
set lucid.rrdimg.domain=''
|
||||||
|
|
||||||
|
add_list lucid.http.publisher=rrdimg
|
||||||
|
add_list lucid.https.publisher=rrdimg
|
||||||
|
|
||||||
|
commit lucid
|
||||||
|
EOF
|
||||||
|
/etc/init.d/lucid restart
|
||||||
|
fi
|
||||||
|
|
||||||
|
start
|
||||||
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
### replace shipped config with symlink
|
### replace shipped config with symlink
|
||||||
if [ ! -L /etc/collectd.conf ]; then
|
if [ ! -L /etc/collectd.conf ]; then
|
||||||
|
@ -13,9 +34,10 @@ start() {
|
||||||
/usr/bin/stat-genconfig > /var/etc/collectd.conf
|
/usr/bin/stat-genconfig > /var/etc/collectd.conf
|
||||||
|
|
||||||
### prepare rrdimg directory
|
### prepare rrdimg directory
|
||||||
if [ ! -L /www/rrdimg ]; then
|
if [ "$(uci get luci_statistics.rrdtool.image_path 2>/dev/null)" != "$(uci get lucid.rrdimg.physical 2>/dev/null)" ]; then
|
||||||
imagepath="$(uci get luci_statistics.rrdtool.image_path)"
|
uci set lucid.rrdimg.physical=$(uci get luci_statistics.rrdtool.image_path)
|
||||||
ln -s ${imagepath:-/tmp/rrdimg}/ /www/rrdimg
|
uci commit lucid
|
||||||
|
/etc/init.d/lucid restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### flush LuCI index cache
|
### flush LuCI index cache
|
||||||
|
|
Loading…
Reference in a new issue