From c1380ab36797dc4a9cba5a6aa738019452178d79 Mon Sep 17 00:00:00 2001 From: Matthias Berndt Date: Thu, 4 Jul 2019 00:40:58 +0200 Subject: make luci-app-statistics more extensible --- .../root/usr/bin/stat-genconfig | 194 ++------------------- 1 file changed, 10 insertions(+), 184 deletions(-) (limited to 'applications/luci-app-statistics/root/usr') diff --git a/applications/luci-app-statistics/root/usr/bin/stat-genconfig b/applications/luci-app-statistics/root/usr/bin/stat-genconfig index cb091ae672..df36da419f 100755 --- a/applications/luci-app-statistics/root/usr/bin/stat-genconfig +++ b/applications/luci-app-statistics/root/usr/bin/stat-genconfig @@ -19,6 +19,7 @@ $Id$ require("luci.model.uci") require("luci.sys.iptparser") require("luci.util") +require("nixio.fs") local ipt = luci.sys.iptparser.IptParser() local uci = luci.model.uci.cursor() @@ -270,206 +271,31 @@ end plugins = { - apcups = { - { "Host", "Port" }, - { }, - { } - }, - collectd = { { "BaseDir", "Include", "PIDFile", "PluginDir", "TypesDB", "Interval", "ReadThreads", "Hostname" }, { }, { } }, - - conntrack = { - { }, - { }, - { } - }, - - cpu = { - { }, - { }, - { } - }, - - cpufreq = { - { }, - { }, - { } - }, - - contextswitch = { - { }, - { }, - { } - }, - - csv = { - { "DataDir" }, - { "StoreRates" }, - { } - }, - curl = config_curl, - - df = { - { }, - { "IgnoreSelected" }, - { "Devices", "MountPoints", "FSTypes" } - }, - - disk = { - { }, - { "IgnoreSelected" }, - { "Disks" } - }, - - dns = { - { }, - { }, - { "Interfaces", "IgnoreSources" } - }, - - email = { - { "SocketFile", "SocketGroup", "SocketPerms", "MaxConns" }, - { }, - { } - }, - - entropy = { - { }, - { }, - { } - }, - exec = config_exec, - - interface = { - { }, - { "IgnoreSelected" }, - { "Interfaces" } - }, - iptables = config_iptables, - - irq = { - { }, - { "IgnoreSelected" }, - { "Irqs" } - }, - - iwinfo = { - { }, - { "IgnoreSelected" }, - { "Interfaces" } - }, - - load = { - { }, - { }, - { } - }, - logfile = { { "LogLevel", "File" }, { "Timestamp" }, { } }, - - memory = { - { }, - { }, - { } - }, - - netlink = { - { }, - { "IgnoreSelected" }, - { "Interfaces", "VerboseInterfaces", "QDiscs", "Classes", "Filters" } - }, - network = config_network, +} - nut = { - { }, - { }, - { "UPS" } - }, - - olsrd = { - { "Host", "Port", "CollectLinks","CollectRoutes","CollectTopology"}, - { }, - { } - }, - - openvpn = { - { }, - { "CollectIndividualUsers", "CollectUserCount", "CollectCompression", "ImprovedNamingSchema" }, - { "StatusFile" } - }, - - ping = { - { "TTL", "Interval", "AddressFamily" }, - { }, - { "Hosts" } - }, - - processes = { - { }, - { }, - { "Processes" } - }, - - rrdtool = { - { "DataDir", "StepSize", "HeartBeat", "RRARows", "XFF", "CacheFlush", "CacheTimeout" }, - { "RRASingle" }, - { "RRATimespans" } - }, - - sensors = { - { }, - { "IgnoreSelected" }, - { "Sensor" } - }, - - splash_leases = { - { }, - { }, - { } - }, - - tcpconns = { - { }, - { "ListeningPorts" }, - { "LocalPorts", "RemotePorts" } - }, - - thermal = { - { }, - { "IgnoreSelected" }, - { "Device" } - }, - - unixsock = { - { "SocketFile", "SocketGroup", "SocketPerms" }, - { }, - { } - }, - - uptime = { - { }, - { }, - { } - }, +local plugin_dir = "/usr/lib/lua/luci/statistics/plugins/" +for filename in nixio.fs.dir(plugin_dir) do + local plugin_fun = loadfile(plugin_dir .. filename) + setfenv(plugin_fun, { _ = luci.i18n.translate }) + local plugin = plugin_fun() + local name = filename:gsub("%.lua", "") + plugins[name] = plugin.legend +end - wireless = { - { }, - { }, - { } - }, -} preprocess = { RRATimespans = function(val) -- cgit v1.2.3