make luci-app-statistics more extensible 2818/head
authorMatthias Berndt <matthias_berndt@gmx.de>
Wed, 3 Jul 2019 22:40:58 +0000 (00:40 +0200)
committerMatthias Berndt <matthias_berndt@gmx.de>
Fri, 5 Jul 2019 00:03:13 +0000 (02:03 +0200)
35 files changed:
applications/luci-app-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
applications/luci-app-statistics/luasrc/statistics/plugins/apcups.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/conntrack.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/contextswitch.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/cpu.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/cpufreq.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/csv.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/curl.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/df.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/disk.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/dns.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/email.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/entropy.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/exec.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/interface.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/iptables.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/irq.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/iwinfo.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/load.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/memory.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/netlink.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/network.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/nut.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/olsrd.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/openvpn.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/ping.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/processes.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/rrdtool.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/sensors.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/splash_leases.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/tcpconns.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/thermal.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/unixsock.lua [new file with mode: 0644]
applications/luci-app-statistics/luasrc/statistics/plugins/uptime.lua [new file with mode: 0644]
applications/luci-app-statistics/root/usr/bin/stat-genconfig

index eb7769b85fd4ed7ef3c6f400c94efb00664d9186..4c5db17d83109625cc040e635d0204f4a944cd06 100644 (file)
@@ -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 (file)
index 0000000..c54b550
--- /dev/null
@@ -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 (file)
index 0000000..59f1a00
--- /dev/null
@@ -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 (file)
index 0000000..90b44c2
--- /dev/null
@@ -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 (file)
index 0000000..004a450
--- /dev/null
@@ -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 (file)
index 0000000..29d2b8e
--- /dev/null
@@ -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 (file)
index 0000000..17a8621
--- /dev/null
@@ -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 (file)
index 0000000..04217bd
--- /dev/null
@@ -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 (file)
index 0000000..89acbff
--- /dev/null
@@ -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 (file)
index 0000000..3d6eeb5
--- /dev/null
@@ -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 (file)
index 0000000..4d10b86
--- /dev/null
@@ -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 (file)
index 0000000..6d4c54a
--- /dev/null
@@ -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 (file)
index 0000000..3b48d16
--- /dev/null
@@ -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 (file)
index 0000000..4a972cc
--- /dev/null
@@ -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 (file)
index 0000000..e220267
--- /dev/null
@@ -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 (file)
index 0000000..75006b3
--- /dev/null
@@ -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 (file)
index 0000000..fa17b93
--- /dev/null
@@ -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 (file)
index 0000000..658ff2a
--- /dev/null
@@ -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 (file)
index 0000000..fdd6891
--- /dev/null
@@ -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 (file)
index 0000000..8dee2da
--- /dev/null
@@ -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 (file)
index 0000000..885caf0
--- /dev/null
@@ -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 (file)
index 0000000..5e4e620
--- /dev/null
@@ -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 (file)
index 0000000..c490c4f
--- /dev/null
@@ -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 (file)
index 0000000..0777297
--- /dev/null
@@ -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 (file)
index 0000000..850a995
--- /dev/null
@@ -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 (file)
index 0000000..9ad16d8
--- /dev/null
@@ -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 (file)
index 0000000..cabf8f1
--- /dev/null
@@ -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 (file)
index 0000000..de5b4c7
--- /dev/null
@@ -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 (file)
index 0000000..713ab9a
--- /dev/null
@@ -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 (file)
index 0000000..5640ea2
--- /dev/null
@@ -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 (file)
index 0000000..bb76522
--- /dev/null
@@ -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 (file)
index 0000000..e7e45f2
--- /dev/null
@@ -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 (file)
index 0000000..71f50e1
--- /dev/null
@@ -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 (file)
index 0000000..bb51a6a
--- /dev/null
@@ -0,0 +1,9 @@
+return {
+    legend = {
+               { },
+               { },
+               { }
+       },
+       label = _("Uptime"),
+       category = "general"
+}
index cb091ae6724cf5a007ba87a00fe72a879bba5166..df36da419fc3b55d515f0e965278a7eacf2da17f 100755 (executable)
@@ -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)