summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/luasrc/controller
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-02-08 22:12:17 +0100
committerJo-Philipp Wich <jo@mein.io>2020-02-12 11:59:41 +0100
commite7d22dce50b4a0c50c9f8ae8c18eeb5a37a51b3e (patch)
tree19a86aed11fae3741f8aa4f773d979f30ba13a1d /applications/luci-app-statistics/luasrc/controller
parent2df2958fd6f0206f56116e88693cb7b748e736fa (diff)
luci-app-statistics: convert collectd configuration to client side views
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-statistics/luasrc/controller')
-rw-r--r--applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua56
1 files changed, 1 insertions, 55 deletions
diff --git a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
index 529cc2335a..9bf8bcfb06 100644
--- a/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
+++ b/applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
@@ -9,66 +9,12 @@ function index()
require("nixio.fs")
require("luci.util")
require("luci.statistics.datatree")
- require("luci.jsonc")
-
- -- override entry(): check for existence <plugin>.so where <plugin> is derived from the called path
- function _entry( path, ... )
- local file = path[5] or path[4]
- if nixio.fs.access( "/usr/lib/collectd/" .. file .. ".so" ) then
- entry( path, ... )
- end
- end
-
- local labels = {
- s_output = _("Output plugins"),
- s_general = _("General plugins"),
- s_network = _("Network plugins"),
- }
-
- -- our collectd menu
- local collectd_menu = {
- output = { },
- general = { },
- network = { }
- }
-
- local plugin_dir = "/usr/share/luci/statistics/plugins/"
- for filename in nixio.fs.dir(plugin_dir) do
- local plugin_def = luci.jsonc.parse(nixio.fs.readfile(plugin_dir .. filename))
- if type(plugin_def) == "table" then
- local name = filename:gsub("%.json", "")
- table.insert(collectd_menu[plugin_def.category], name)
- labels[name] = plugin_def.title
- end
- end
-- create toplevel menu nodes
local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80)
st.index = true
- entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), _("Setup"), 20).subindex = true
-
-
- -- populate collectd plugin menu
- local index = 1
- for section, plugins in luci.util.kspairs( collectd_menu ) do
- local e = entry(
- { "admin", "statistics", "collectd", section },
- firstchild(), labels["s_"..section], index * 10
- )
-
- e.index = true
-
- for j, plugin in luci.util.vspairs( plugins ) do
- _entry(
- { "admin", "statistics", "collectd", section, plugin },
- cbi("luci_statistics/" .. plugin ),
- labels[plugin] or plugin, j * 10
- )
- end
-
- index = index + 1
- end
+ entry({"admin", "statistics", "collectd"}, view("statistics/collectd"), _("Setup"), 20).subindex = true
-- output views
local page = entry( { "admin", "statistics", "graph" }, template("admin_statistics/index"), _("Graphs"), 10)