From c1380ab36797dc4a9cba5a6aa738019452178d79 Mon Sep 17 00:00:00 2001 From: Matthias Berndt Date: Thu, 4 Jul 2019 00:40:58 +0200 Subject: [PATCH] make luci-app-statistics more extensible --- .../luci_statistics/luci_statistics.lua | 54 ++--- .../luasrc/statistics/plugins/apcups.lua | 9 + .../luasrc/statistics/plugins/conntrack.lua | 9 + .../statistics/plugins/contextswitch.lua | 9 + .../luasrc/statistics/plugins/cpu.lua | 9 + .../luasrc/statistics/plugins/cpufreq.lua | 9 + .../luasrc/statistics/plugins/csv.lua | 9 + .../luasrc/statistics/plugins/curl.lua | 4 + .../luasrc/statistics/plugins/df.lua | 9 + .../luasrc/statistics/plugins/disk.lua | 9 + .../luasrc/statistics/plugins/dns.lua | 9 + .../luasrc/statistics/plugins/email.lua | 9 + .../luasrc/statistics/plugins/entropy.lua | 9 + .../luasrc/statistics/plugins/exec.lua | 4 + .../luasrc/statistics/plugins/interface.lua | 9 + .../luasrc/statistics/plugins/iptables.lua | 4 + .../luasrc/statistics/plugins/irq.lua | 9 + .../luasrc/statistics/plugins/iwinfo.lua | 9 + .../luasrc/statistics/plugins/load.lua | 9 + .../luasrc/statistics/plugins/memory.lua | 9 + .../luasrc/statistics/plugins/netlink.lua | 9 + .../luasrc/statistics/plugins/network.lua | 4 + .../luasrc/statistics/plugins/nut.lua | 9 + .../luasrc/statistics/plugins/olsrd.lua | 9 + .../luasrc/statistics/plugins/openvpn.lua | 9 + .../luasrc/statistics/plugins/ping.lua | 9 + .../luasrc/statistics/plugins/processes.lua | 9 + .../luasrc/statistics/plugins/rrdtool.lua | 9 + .../luasrc/statistics/plugins/sensors.lua | 9 + .../statistics/plugins/splash_leases.lua | 9 + .../luasrc/statistics/plugins/tcpconns.lua | 9 + .../luasrc/statistics/plugins/thermal.lua | 9 + .../luasrc/statistics/plugins/unixsock.lua | 9 + .../luasrc/statistics/plugins/uptime.lua | 9 + .../root/usr/bin/stat-genconfig | 194 +----------------- 35 files changed, 300 insertions(+), 225 deletions(-) create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/apcups.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/conntrack.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/contextswitch.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/cpufreq.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/csv.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/curl.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/df.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/disk.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/dns.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/email.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/entropy.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/exec.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/interface.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/iptables.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/irq.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/iwinfo.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/load.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/netlink.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/network.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/nut.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/olsrd.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/openvpn.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/ping.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/processes.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/rrdtool.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/sensors.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/splash_leases.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/tcpconns.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/thermal.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/unixsock.lua create mode 100644 applications/luci-app-statistics/luasrc/statistics/plugins/uptime.lua 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 eb7769b85f..4c5db17d83 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 @@ -22,53 +22,25 @@ function index() s_output = _("Output plugins"), s_general = _("General plugins"), s_network = _("Network plugins"), - - apcups = _("APC UPS"), - conntrack = _("Conntrack"), - contextswitch = _("Context Switches"), - cpu = _("Processor"), - cpufreq = _("CPU Frequency"), - csv = _("CSV Output"), - curl = _("cUrl"), - df = _("Disk Space Usage"), - disk = _("Disk Usage"), - dns = _("DNS"), - email = _("Email"), - entropy = _("Entropy"), - exec = _("Exec"), - interface = _("Interfaces"), - iptables = _("Firewall"), - irq = _("Interrupts"), - iwinfo = _("Wireless"), - load = _("System Load"), - memory = _("Memory"), - netlink = _("Netlink"), - network = _("Network"), - nut = _("UPS"), - olsrd = _("OLSRd"), - openvpn = _("OpenVPN"), - ping = _("Ping"), - processes = _("Processes"), - rrdtool = _("RRDTool"), - sensors = _("Sensors"), - splash_leases = _("Splash Leases"), - tcpconns = _("TCP Connections"), - thermal = _("Thermal"), - unixsock = _("UnixSock"), - uptime = _("Uptime") } -- our collectd menu local collectd_menu = { - output = { "csv", "network", "rrdtool", "unixsock" }, - general = { "apcups", "contextswitch", "cpu", "cpufreq", "df", - "disk", "email", "entropy", "exec", "irq", "load", "memory", - "nut", "processes", "sensors", "thermal", "uptime" }, - network = { "conntrack", "curl", "dns", "interface", "iptables", - "netlink", "olsrd", "openvpn", "ping", - "splash_leases", "tcpconns", "iwinfo" } + output = { }, + general = { }, + network = { } } + 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", "") + table.insert(collectd_menu[plugin.category], name) + labels[name] = plugin.label + end + -- create toplevel menu nodes local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80) st.index = true diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/apcups.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/apcups.lua new file mode 100644 index 0000000000..c54b550c36 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/apcups.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "Host", "Port" }, + { }, + { } + }, + label = _("APC UPS"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/conntrack.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/conntrack.lua new file mode 100644 index 0000000000..59f1a006b2 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/conntrack.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Conntrack"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/contextswitch.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/contextswitch.lua new file mode 100644 index 0000000000..90b44c2e7d --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/contextswitch.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Context Switches"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua new file mode 100644 index 0000000000..004a450eec --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Processor"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/cpufreq.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/cpufreq.lua new file mode 100644 index 0000000000..29d2b8e80a --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/cpufreq.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("CPU Frequency"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/csv.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/csv.lua new file mode 100644 index 0000000000..17a8621afe --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/csv.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "DataDir" }, + { "StoreRates" }, + { } + }, + label = _("CSV Output"), + category = "output" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/curl.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/curl.lua new file mode 100644 index 0000000000..04217bdd6e --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/curl.lua @@ -0,0 +1,4 @@ +return { + label = _("cUrl"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/df.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/df.lua new file mode 100644 index 0000000000..89acbff0ff --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/df.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Devices", "MountPoints", "FSTypes" } + }, + label = _("Disk Space Usage"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/disk.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/disk.lua new file mode 100644 index 0000000000..3d6eeb5ab4 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/disk.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Disks" } + }, + label = _("Disk Usage"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/dns.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/dns.lua new file mode 100644 index 0000000000..4d10b86580 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/dns.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { "Interfaces", "IgnoreSources" } + }, + label = _("DNS"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/email.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/email.lua new file mode 100644 index 0000000000..6d4c54a574 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/email.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "SocketFile", "SocketGroup", "SocketPerms", "MaxConns" }, + { }, + { } + }, + label = _("Email"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/entropy.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/entropy.lua new file mode 100644 index 0000000000..3b48d1644d --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/entropy.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Entropy"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/exec.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/exec.lua new file mode 100644 index 0000000000..4a972ccc84 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/exec.lua @@ -0,0 +1,4 @@ +return { + label = _("Exec"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/interface.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/interface.lua new file mode 100644 index 0000000000..e22026789b --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/interface.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Interfaces" } + }, + label = _("Interfaces"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/iptables.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/iptables.lua new file mode 100644 index 0000000000..75006b306b --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/iptables.lua @@ -0,0 +1,4 @@ +return { + label = _("Firewall"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/irq.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/irq.lua new file mode 100644 index 0000000000..fa17b939a8 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/irq.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Irqs" } + }, + label = _("Interrupts"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/iwinfo.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/iwinfo.lua new file mode 100644 index 0000000000..658ff2aebe --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/iwinfo.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Interfaces" } + }, + label = _("Wireless"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/load.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/load.lua new file mode 100644 index 0000000000..fdd6891e2f --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/load.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("System Load"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua new file mode 100644 index 0000000000..8dee2dafcd --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Memory"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/netlink.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/netlink.lua new file mode 100644 index 0000000000..885caf0bda --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/netlink.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Interfaces", "VerboseInterfaces", "QDiscs", "Classes", "Filters" } + }, + label = _("Netlink"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/network.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/network.lua new file mode 100644 index 0000000000..5e4e620177 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/network.lua @@ -0,0 +1,4 @@ +return { + label = _("Network"), + category = "output" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/nut.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/nut.lua new file mode 100644 index 0000000000..c490c4fd7a --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/nut.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { "UPS" } + }, + label = _("UPS"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/olsrd.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/olsrd.lua new file mode 100644 index 0000000000..077729788d --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/olsrd.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "Host", "Port", "CollectLinks","CollectRoutes","CollectTopology"}, + { }, + { } + }, + label = _("OLSRd"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/openvpn.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/openvpn.lua new file mode 100644 index 0000000000..850a995bc2 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/openvpn.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "CollectIndividualUsers", "CollectUserCount", "CollectCompression", "ImprovedNamingSchema" }, + { "StatusFile" } + }, + label = _("OpenVPN"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/ping.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/ping.lua new file mode 100644 index 0000000000..9ad16d802b --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/ping.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "TTL", "Interval", "AddressFamily" }, + { }, + { "Hosts" } + }, + label = _("Ping"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/processes.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/processes.lua new file mode 100644 index 0000000000..cabf8f1e41 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/processes.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { "Processes" } + }, + label = _("Processes"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/rrdtool.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/rrdtool.lua new file mode 100644 index 0000000000..de5b4c7ecd --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/rrdtool.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "DataDir", "StepSize", "HeartBeat", "RRARows", "XFF", "CacheFlush", "CacheTimeout" }, + { "RRASingle" }, + { "RRATimespans" } + }, + label = _("RRDTool"), + category = "output" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/sensors.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/sensors.lua new file mode 100644 index 0000000000..713ab9aef4 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/sensors.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Sensor" } + }, + label = _("Sensors"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/splash_leases.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/splash_leases.lua new file mode 100644 index 0000000000..5640ea2bf7 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/splash_leases.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Splash Leases"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/tcpconns.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/tcpconns.lua new file mode 100644 index 0000000000..bb76522d3a --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/tcpconns.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "ListeningPorts" }, + { "LocalPorts", "RemotePorts" } + }, + label = _("TCP Connections"), + category = "network" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/thermal.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/thermal.lua new file mode 100644 index 0000000000..e7e45f256b --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/thermal.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { "IgnoreSelected" }, + { "Device" } + }, + label = _("Thermal"), + category = "general" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/unixsock.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/unixsock.lua new file mode 100644 index 0000000000..71f50e1dbb --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/unixsock.lua @@ -0,0 +1,9 @@ +return { + legend = { + { "SocketFile", "SocketGroup", "SocketPerms" }, + { }, + { } + }, + label = _("UnixSock"), + category = "output" +} diff --git a/applications/luci-app-statistics/luasrc/statistics/plugins/uptime.lua b/applications/luci-app-statistics/luasrc/statistics/plugins/uptime.lua new file mode 100644 index 0000000000..bb51a6a964 --- /dev/null +++ b/applications/luci-app-statistics/luasrc/statistics/plugins/uptime.lua @@ -0,0 +1,9 @@ +return { + legend = { + { }, + { }, + { } + }, + label = _("Uptime"), + category = "general" +} 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) -- 2.30.2