make luci-app-statistics more extensible
This commit is contained in:
parent
f56a6df49c
commit
c1380ab367
35 changed files with 301 additions and 226 deletions
|
@ -22,53 +22,25 @@ function index()
|
||||||
s_output = _("Output plugins"),
|
s_output = _("Output plugins"),
|
||||||
s_general = _("General plugins"),
|
s_general = _("General plugins"),
|
||||||
s_network = _("Network 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
|
-- our collectd menu
|
||||||
local collectd_menu = {
|
local collectd_menu = {
|
||||||
output = { "csv", "network", "rrdtool", "unixsock" },
|
output = { },
|
||||||
general = { "apcups", "contextswitch", "cpu", "cpufreq", "df",
|
general = { },
|
||||||
"disk", "email", "entropy", "exec", "irq", "load", "memory",
|
network = { }
|
||||||
"nut", "processes", "sensors", "thermal", "uptime" },
|
|
||||||
network = { "conntrack", "curl", "dns", "interface", "iptables",
|
|
||||||
"netlink", "olsrd", "openvpn", "ping",
|
|
||||||
"splash_leases", "tcpconns", "iwinfo" }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
-- create toplevel menu nodes
|
||||||
local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80)
|
local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80)
|
||||||
st.index = true
|
st.index = true
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "Host", "Port" },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("APC UPS"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Conntrack"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Context Switches"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Processor"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("CPU Frequency"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "DataDir" },
|
||||||
|
{ "StoreRates" },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("CSV Output"),
|
||||||
|
category = "output"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
return {
|
||||||
|
label = _("cUrl"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Devices", "MountPoints", "FSTypes" }
|
||||||
|
},
|
||||||
|
label = _("Disk Space Usage"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Disks" }
|
||||||
|
},
|
||||||
|
label = _("Disk Usage"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ "Interfaces", "IgnoreSources" }
|
||||||
|
},
|
||||||
|
label = _("DNS"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "SocketFile", "SocketGroup", "SocketPerms", "MaxConns" },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Email"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Entropy"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
return {
|
||||||
|
label = _("Exec"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Interfaces" }
|
||||||
|
},
|
||||||
|
label = _("Interfaces"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
return {
|
||||||
|
label = _("Firewall"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Irqs" }
|
||||||
|
},
|
||||||
|
label = _("Interrupts"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Interfaces" }
|
||||||
|
},
|
||||||
|
label = _("Wireless"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("System Load"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Memory"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Interfaces", "VerboseInterfaces", "QDiscs", "Classes", "Filters" }
|
||||||
|
},
|
||||||
|
label = _("Netlink"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
return {
|
||||||
|
label = _("Network"),
|
||||||
|
category = "output"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ "UPS" }
|
||||||
|
},
|
||||||
|
label = _("UPS"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "Host", "Port", "CollectLinks","CollectRoutes","CollectTopology"},
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("OLSRd"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "CollectIndividualUsers", "CollectUserCount", "CollectCompression", "ImprovedNamingSchema" },
|
||||||
|
{ "StatusFile" }
|
||||||
|
},
|
||||||
|
label = _("OpenVPN"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "TTL", "Interval", "AddressFamily" },
|
||||||
|
{ },
|
||||||
|
{ "Hosts" }
|
||||||
|
},
|
||||||
|
label = _("Ping"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ "Processes" }
|
||||||
|
},
|
||||||
|
label = _("Processes"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "DataDir", "StepSize", "HeartBeat", "RRARows", "XFF", "CacheFlush", "CacheTimeout" },
|
||||||
|
{ "RRASingle" },
|
||||||
|
{ "RRATimespans" }
|
||||||
|
},
|
||||||
|
label = _("RRDTool"),
|
||||||
|
category = "output"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Sensor" }
|
||||||
|
},
|
||||||
|
label = _("Sensors"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Splash Leases"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "ListeningPorts" },
|
||||||
|
{ "LocalPorts", "RemotePorts" }
|
||||||
|
},
|
||||||
|
label = _("TCP Connections"),
|
||||||
|
category = "network"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ "IgnoreSelected" },
|
||||||
|
{ "Device" }
|
||||||
|
},
|
||||||
|
label = _("Thermal"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ "SocketFile", "SocketGroup", "SocketPerms" },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("UnixSock"),
|
||||||
|
category = "output"
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
legend = {
|
||||||
|
{ },
|
||||||
|
{ },
|
||||||
|
{ }
|
||||||
|
},
|
||||||
|
label = _("Uptime"),
|
||||||
|
category = "general"
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ $Id$
|
||||||
require("luci.model.uci")
|
require("luci.model.uci")
|
||||||
require("luci.sys.iptparser")
|
require("luci.sys.iptparser")
|
||||||
require("luci.util")
|
require("luci.util")
|
||||||
|
require("nixio.fs")
|
||||||
|
|
||||||
local ipt = luci.sys.iptparser.IptParser()
|
local ipt = luci.sys.iptparser.IptParser()
|
||||||
local uci = luci.model.uci.cursor()
|
local uci = luci.model.uci.cursor()
|
||||||
|
@ -270,207 +271,32 @@ end
|
||||||
|
|
||||||
|
|
||||||
plugins = {
|
plugins = {
|
||||||
apcups = {
|
|
||||||
{ "Host", "Port" },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
collectd = {
|
collectd = {
|
||||||
{ "BaseDir", "Include", "PIDFile", "PluginDir", "TypesDB", "Interval", "ReadThreads", "Hostname" },
|
{ "BaseDir", "Include", "PIDFile", "PluginDir", "TypesDB", "Interval", "ReadThreads", "Hostname" },
|
||||||
{ },
|
{ },
|
||||||
{ }
|
{ }
|
||||||
},
|
},
|
||||||
|
|
||||||
conntrack = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
cpu = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
cpufreq = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
contextswitch = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
csv = {
|
|
||||||
{ "DataDir" },
|
|
||||||
{ "StoreRates" },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
curl = config_curl,
|
curl = config_curl,
|
||||||
|
|
||||||
df = {
|
|
||||||
{ },
|
|
||||||
{ "IgnoreSelected" },
|
|
||||||
{ "Devices", "MountPoints", "FSTypes" }
|
|
||||||
},
|
|
||||||
|
|
||||||
disk = {
|
|
||||||
{ },
|
|
||||||
{ "IgnoreSelected" },
|
|
||||||
{ "Disks" }
|
|
||||||
},
|
|
||||||
|
|
||||||
dns = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ "Interfaces", "IgnoreSources" }
|
|
||||||
},
|
|
||||||
|
|
||||||
email = {
|
|
||||||
{ "SocketFile", "SocketGroup", "SocketPerms", "MaxConns" },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
entropy = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
exec = config_exec,
|
exec = config_exec,
|
||||||
|
|
||||||
interface = {
|
|
||||||
{ },
|
|
||||||
{ "IgnoreSelected" },
|
|
||||||
{ "Interfaces" }
|
|
||||||
},
|
|
||||||
|
|
||||||
iptables = config_iptables,
|
iptables = config_iptables,
|
||||||
|
|
||||||
irq = {
|
|
||||||
{ },
|
|
||||||
{ "IgnoreSelected" },
|
|
||||||
{ "Irqs" }
|
|
||||||
},
|
|
||||||
|
|
||||||
iwinfo = {
|
|
||||||
{ },
|
|
||||||
{ "IgnoreSelected" },
|
|
||||||
{ "Interfaces" }
|
|
||||||
},
|
|
||||||
|
|
||||||
load = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
logfile = {
|
logfile = {
|
||||||
{ "LogLevel", "File" },
|
{ "LogLevel", "File" },
|
||||||
{ "Timestamp" },
|
{ "Timestamp" },
|
||||||
{ }
|
{ }
|
||||||
},
|
},
|
||||||
|
|
||||||
memory = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
netlink = {
|
|
||||||
{ },
|
|
||||||
{ "IgnoreSelected" },
|
|
||||||
{ "Interfaces", "VerboseInterfaces", "QDiscs", "Classes", "Filters" }
|
|
||||||
},
|
|
||||||
|
|
||||||
network = config_network,
|
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 = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
|
|
||||||
wireless = {
|
|
||||||
{ },
|
|
||||||
{ },
|
|
||||||
{ }
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
preprocess = {
|
preprocess = {
|
||||||
RRATimespans = function(val)
|
RRATimespans = function(val)
|
||||||
local rv = { }
|
local rv = { }
|
||||||
|
|
Loading…
Reference in a new issue