+--[[
+
+Luci statistics - rrd data tree builder
+(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+]]--
+
module("luci.statistics.datatree", package.seeall)
local util = require("luci.util")
local sys = require("luci.sys")
local fs = require("luci.fs")
-local uci = require("luci.model.uci").Session()
-local sections, names = uci:sections( "luci_statistics" )
+local uci = require("luci.model.uci").cursor()
+local sections = uci:get_all("luci_statistics")
Instance = util.class()
end
function Instance._scan( self )
- for i, plugin in ipairs( fs.dir( self._libdir ) ) do
- if plugin:match("%w+.so") then
- self._plugins[ plugin:gsub(".so", "") ] = { }
+ local dirs = fs.dir( self:_mkpath() )
+ if not dirs then
+ return
+ end
+
+-- for i, plugin in ipairs( dirs ) do
+-- 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