diff options
35 files changed, 300 insertions, 225 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 eb7769b85..4c5db17d8 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 000000000..c54b550c3 --- /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 000000000..59f1a006b --- /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 000000000..90b44c2e7 --- /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 000000000..004a450ee --- /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 000000000..29d2b8e80 --- /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 000000000..17a8621af --- /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 000000000..04217bdd6 --- /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 000000000..89acbff0f --- /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 000000000..3d6eeb5ab --- /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 000000000..4d10b8658 --- /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 000000000..6d4c54a57 --- /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 000000000..3b48d1644 --- /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 000000000..4a972ccc8 --- /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 000000000..e22026789 --- /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 000000000..75006b306 --- /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 000000000..fa17b939a --- /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 000000000..658ff2aeb --- /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 000000000..fdd6891e2 --- /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 000000000..8dee2dafc --- /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 000000000..885caf0bd --- /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 000000000..5e4e62017 --- /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 000000000..c490c4fd7 --- /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 000000000..077729788 --- /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 000000000..850a995bc --- /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 000000000..9ad16d802 --- /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 000000000..cabf8f1e4 --- /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 000000000..de5b4c7ec --- /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 000000000..713ab9aef --- /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 000000000..5640ea2bf --- /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 000000000..bb76522d3 --- /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 000000000..e7e45f256 --- /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 000000000..71f50e1db --- /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 000000000..bb51a6a96 --- /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 cb091ae67..df36da419 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) |