applications/luci-statistics: rework handling of index and detail graphs
Instead of coding the display logic into the graph models, simply annotate graph models with .detail = true/false and let the renderer decide which to pick when.
This commit is contained in:
parent
239672e76b
commit
e046455389
7 changed files with 143 additions and 146 deletions
|
@ -513,20 +513,20 @@ function Graph.render( self, plugin, plugin_instance, is_index )
|
||||||
|
|
||||||
-- get diagram definitions
|
-- get diagram definitions
|
||||||
for i, opts in ipairs( self:_forcelol( def.rrdargs( self, plugin, plugin_instance, nil, is_index ) ) ) do
|
for i, opts in ipairs( self:_forcelol( def.rrdargs( self, plugin, plugin_instance, nil, is_index ) ) ) do
|
||||||
|
if not is_index or not opts.detail then
|
||||||
|
_images[i] = { }
|
||||||
|
|
||||||
_images[i] = { }
|
-- get diagram definition instances
|
||||||
|
local diagrams = self:_generic( opts, plugin, plugin_instance, nil, i )
|
||||||
|
|
||||||
-- get diagram definition instances
|
-- render all diagrams
|
||||||
local diagrams = self:_generic( opts, plugin, plugin_instance, nil, i )
|
for j, def in ipairs( diagrams ) do
|
||||||
|
-- remember image
|
||||||
|
_images[i][j] = def[1]
|
||||||
|
|
||||||
-- render all diagrams
|
-- exec
|
||||||
for j, def in ipairs( diagrams ) do
|
self:_rrdtool( def )
|
||||||
|
end
|
||||||
-- remember image
|
|
||||||
_images[i][j] = def[1]
|
|
||||||
|
|
||||||
-- exec
|
|
||||||
self:_rrdtool( def )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
vlabel = "Bytes/s",
|
vlabel = "Bytes/s",
|
||||||
number_format = "%5.1lf%sB/s",
|
number_format = "%5.1lf%sB/s",
|
||||||
|
|
||||||
|
detail = true,
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
types = { "disk_octets" },
|
types = { "disk_octets" },
|
||||||
sources = {
|
sources = {
|
||||||
|
|
|
@ -53,7 +53,7 @@ function rrdargs( graph, plugin, plugin_instance )
|
||||||
--
|
--
|
||||||
local packets = {
|
local packets = {
|
||||||
title = "%H: Netlink - Packets on %pi",
|
title = "%H: Netlink - Packets on %pi",
|
||||||
vlabel = "Packets/s",
|
vlabel = "Packets/s", detail = true,
|
||||||
|
|
||||||
-- diagram data description
|
-- diagram data description
|
||||||
data = {
|
data = {
|
||||||
|
@ -123,7 +123,7 @@ function rrdargs( graph, plugin, plugin_instance )
|
||||||
--
|
--
|
||||||
local multicast = {
|
local multicast = {
|
||||||
title = "%H: Netlink - Multicast on %pi",
|
title = "%H: Netlink - Multicast on %pi",
|
||||||
vlabel = "Packets/s",
|
vlabel = "Packets/s", detail = true,
|
||||||
|
|
||||||
-- diagram data description
|
-- diagram data description
|
||||||
data = {
|
data = {
|
||||||
|
@ -147,7 +147,7 @@ function rrdargs( graph, plugin, plugin_instance )
|
||||||
--
|
--
|
||||||
local collisions = {
|
local collisions = {
|
||||||
title = "%H: Netlink - Collisions on %pi",
|
title = "%H: Netlink - Collisions on %pi",
|
||||||
vlabel = "Collisions/s",
|
vlabel = "Collisions/s", detail = true,
|
||||||
|
|
||||||
-- diagram data description
|
-- diagram data description
|
||||||
data = {
|
data = {
|
||||||
|
@ -171,7 +171,7 @@ function rrdargs( graph, plugin, plugin_instance )
|
||||||
--
|
--
|
||||||
local errors = {
|
local errors = {
|
||||||
title = "%H: Netlink - Errors on %pi",
|
title = "%H: Netlink - Errors on %pi",
|
||||||
vlabel = "Errors/s",
|
vlabel = "Errors/s", detail = true,
|
||||||
|
|
||||||
-- diagram data description
|
-- diagram data description
|
||||||
data = {
|
data = {
|
||||||
|
|
|
@ -15,8 +15,7 @@ module("luci.statistics.rrdtool.definitions.olsrd", package.seeall)
|
||||||
|
|
||||||
local tree = luci.statistics.datatree.Instance()
|
local tree = luci.statistics.datatree.Instance()
|
||||||
|
|
||||||
function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
|
|
||||||
local g = { }
|
local g = { }
|
||||||
|
|
||||||
if plugin_instance == "routes" then
|
if plugin_instance == "routes" then
|
||||||
|
@ -35,33 +34,31 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not is_index then
|
g[#g+1] = {
|
||||||
g[#g+1] = {
|
title = "%H: Average route ETX", vlabel = "ETX", detail = true,
|
||||||
title = "%H: Average route ETX", vlabel = "ETX",
|
number_format = "%5.1lf",data = {
|
||||||
number_format = "%5.1lf",data = {
|
instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
|
||||||
instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
|
types = { "route_etx" },
|
||||||
types = { "route_etx" },
|
options = {
|
||||||
options = {
|
route_etx = {
|
||||||
route_etx = {
|
title = "Average route ETX"
|
||||||
title = "Average route ETX"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g[#g+1] = {
|
g[#g+1] = {
|
||||||
title = "%H: Average route metric", vlabel = "metric",
|
title = "%H: Average route metric", vlabel = "metric", detail = true,
|
||||||
number_format = "%5.1lf", data = {
|
number_format = "%5.1lf", data = {
|
||||||
instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
|
instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
|
||||||
types = { "route_metric" },
|
types = { "route_metric" },
|
||||||
options = {
|
options = {
|
||||||
route_metric = {
|
route_metric = {
|
||||||
title = "Average route metric"
|
title = "Average route metric"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
|
|
||||||
elseif plugin_instance == "links" then
|
elseif plugin_instance == "links" then
|
||||||
|
|
||||||
|
@ -80,40 +77,39 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not is_index then
|
local instances = tree:data_instances(plugin, plugin_instance, "signal_quality")
|
||||||
local instances = tree:data_instances(plugin, plugin_instance, "signal_quality")
|
table.sort(instances)
|
||||||
table.sort(instances)
|
|
||||||
|
|
||||||
-- define one diagram per host, containing the rx and lq values
|
-- define one diagram per host, containing the rx and lq values
|
||||||
local i
|
local i
|
||||||
for i = 1, #instances, 2 do
|
for i = 1, #instances, 2 do
|
||||||
local dsn1 = "signal_quality_%s_value" % instances[i]:gsub("[^%w]+", "_")
|
local dsn1 = "signal_quality_%s_value" % instances[i]:gsub("[^%w]+", "_")
|
||||||
local dsn2 = "signal_quality_%s_value" % instances[i+1]:gsub("[^%w]+", "_")
|
local dsn2 = "signal_quality_%s_value" % instances[i+1]:gsub("[^%w]+", "_")
|
||||||
local host = instances[i]:match("^[^%-]+%-([^%-]+)%-.+")
|
local host = instances[i]:match("^[^%-]+%-([^%-]+)%-.+")
|
||||||
|
|
||||||
g[#g+1] = {
|
g[#g+1] = {
|
||||||
title = "%H: Signal Quality" .. " (" .. (host or "avg") ..")", vlabel = "ETX",
|
title = "%H: Signal Quality" .. " (" .. (host or "avg") ..")", vlabel = "ETX",
|
||||||
number_format = "%5.2lf", data = {
|
number_format = "%5.2lf", detail = true,
|
||||||
types = { "signal_quality" },
|
data = {
|
||||||
|
types = { "signal_quality" },
|
||||||
|
|
||||||
instances = {
|
instances = {
|
||||||
signal_quality = { instances[i], instances[i+1] },
|
signal_quality = { instances[i], instances[i+1] },
|
||||||
},
|
},
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
[dsn1] = {
|
[dsn1] = {
|
||||||
color = "00ff00",
|
color = "00ff00",
|
||||||
title = "LQ (%s)" % (host or "avg"),
|
title = "LQ (%s)" % (host or "avg"),
|
||||||
},
|
},
|
||||||
[dsn2] = {
|
[dsn2] = {
|
||||||
color = "0000ff",
|
color = "0000ff",
|
||||||
title = "NLQ (%s)" % (host or "avg"),
|
title = "NLQ (%s)" % (host or "avg"),
|
||||||
flip = true
|
flip = true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif plugin_instance == "topology" then
|
elseif plugin_instance == "topology" then
|
||||||
|
@ -124,7 +120,7 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
||||||
instances = { "" },
|
instances = { "" },
|
||||||
types = { "links" },
|
types = { "links" },
|
||||||
options = {
|
options = {
|
||||||
links = { -- or: links__value is aber egal weils eh nur eines davon gibt
|
links = {
|
||||||
color = "0000ff",
|
color = "0000ff",
|
||||||
title = "Total number of links"
|
title = "Total number of links"
|
||||||
}
|
}
|
||||||
|
@ -132,21 +128,20 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if not is_index then
|
g[#g+1] = {
|
||||||
g[#g+1] = {
|
title= "%H: Average signal quality", vlabel = "n",
|
||||||
title= "%H: Average signal quality", vlabel = "n",
|
number_format = "%5.2lf", detail = true,
|
||||||
number_format = "%5.2lf", data = {
|
data = {
|
||||||
instances = { "average" }, -- exclude possible per-ip stuff
|
instances = { "average" }, -- exclude possible per-ip stuff
|
||||||
types = { "signal_quality" },
|
types = { "signal_quality" },
|
||||||
options = {
|
options = {
|
||||||
signal_quality = {
|
signal_quality = {
|
||||||
color = "0000ff",
|
color = "0000ff",
|
||||||
title = "Average signal quality"
|
title = "Average signal quality"
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
return g
|
return g
|
||||||
|
|
|
@ -15,7 +15,7 @@ $Id: ping.lua 6810 2011-01-29 03:33:48Z jow $
|
||||||
|
|
||||||
module("luci.statistics.rrdtool.definitions.ping", package.seeall)
|
module("luci.statistics.rrdtool.definitions.ping", package.seeall)
|
||||||
|
|
||||||
function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
return {
|
return {
|
||||||
-- Ping roundtrip time
|
-- Ping roundtrip time
|
||||||
{ title = "%H: ICMP Round Trip Time", vlabel = "ms",
|
{ title = "%H: ICMP Round Trip Time", vlabel = "ms",
|
||||||
|
|
|
@ -15,10 +15,10 @@ $Id$
|
||||||
|
|
||||||
module("luci.statistics.rrdtool.definitions.processes", package.seeall)
|
module("luci.statistics.rrdtool.definitions.processes", package.seeall)
|
||||||
|
|
||||||
function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
|
|
||||||
if is_index then
|
return {
|
||||||
return {
|
{
|
||||||
title = "%H: Processes",
|
title = "%H: Processes",
|
||||||
vlabel = "Processes/s",
|
vlabel = "Processes/s",
|
||||||
data = {
|
data = {
|
||||||
|
@ -37,73 +37,74 @@ function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
|
||||||
ps_state_zombies = { color = "ff0000" }
|
ps_state_zombies = { color = "ff0000" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
else
|
|
||||||
return {
|
{
|
||||||
{
|
title = "%H: CPU time used by %pi",
|
||||||
title = "%H: CPU time used by %pi",
|
vlabel = "Jiffies",
|
||||||
vlabel = "Jiffies",
|
data = {
|
||||||
data = {
|
sources = {
|
||||||
sources = {
|
ps_cputime = { "syst", "user" }
|
||||||
ps_cputime = { "syst", "user" }
|
},
|
||||||
|
|
||||||
|
options = {
|
||||||
|
ps_cputime__user = {
|
||||||
|
color = "0000ff",
|
||||||
|
overlay = true
|
||||||
},
|
},
|
||||||
|
|
||||||
options = {
|
ps_cputime__syst = {
|
||||||
ps_cputime__user = {
|
color = "ff0000",
|
||||||
color = "0000ff",
|
overlay = true
|
||||||
overlay = true
|
|
||||||
},
|
|
||||||
|
|
||||||
ps_cputime__syst = {
|
|
||||||
color = "ff0000",
|
|
||||||
overlay = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
title = "%H: Threads and processes belonging to %pi",
|
|
||||||
vlabel = "Count",
|
|
||||||
data = {
|
|
||||||
sources = {
|
|
||||||
ps_count = { "threads", "processes" }
|
|
||||||
},
|
|
||||||
|
|
||||||
options = {
|
|
||||||
ps_count__threads = { color = "00ff00" },
|
|
||||||
ps_count__processes = { color = "0000bb" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
title = "%H: Page faults in %pi",
|
|
||||||
vlabel = "Pagefaults",
|
|
||||||
data = {
|
|
||||||
sources = {
|
|
||||||
ps_pagefaults = { "minflt", "majflt" }
|
|
||||||
},
|
|
||||||
|
|
||||||
options = {
|
|
||||||
ps_pagefaults__minflt = { color = "ff0000" },
|
|
||||||
ps_pagefaults__majflt = { color = "ff5500" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
title = "%H: Virtual memory size of %pi",
|
|
||||||
vlabel = "Bytes",
|
|
||||||
number_format = "%5.1lf%sB",
|
|
||||||
data = {
|
|
||||||
types = { "ps_rss" },
|
|
||||||
|
|
||||||
options = {
|
|
||||||
ps_rss = { color = "0000ff" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title = "%H: Threads and processes belonging to %pi",
|
||||||
|
vlabel = "Count",
|
||||||
|
detail = true,
|
||||||
|
data = {
|
||||||
|
sources = {
|
||||||
|
ps_count = { "threads", "processes" }
|
||||||
|
},
|
||||||
|
|
||||||
|
options = {
|
||||||
|
ps_count__threads = { color = "00ff00" },
|
||||||
|
ps_count__processes = { color = "0000bb" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title = "%H: Page faults in %pi",
|
||||||
|
vlabel = "Pagefaults",
|
||||||
|
detail = true,
|
||||||
|
data = {
|
||||||
|
sources = {
|
||||||
|
ps_pagefaults = { "minflt", "majflt" }
|
||||||
|
},
|
||||||
|
|
||||||
|
options = {
|
||||||
|
ps_pagefaults__minflt = { color = "ff0000" },
|
||||||
|
ps_pagefaults__majflt = { color = "ff5500" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title = "%H: Virtual memory size of %pi",
|
||||||
|
vlabel = "Bytes",
|
||||||
|
detail = true,
|
||||||
|
number_format = "%5.1lf%sB",
|
||||||
|
data = {
|
||||||
|
types = { "ps_rss" },
|
||||||
|
|
||||||
|
options = {
|
||||||
|
ps_rss = { color = "0000ff" }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
end
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,9 +28,8 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
"LAST_ACK", "TIME_WAIT", "CLOSING", "CLOSE_WAIT",
|
"LAST_ACK", "TIME_WAIT", "CLOSING", "CLOSE_WAIT",
|
||||||
"CLOSED", "FIN_WAIT1", "FIN_WAIT2"
|
"CLOSED", "FIN_WAIT1", "FIN_WAIT2"
|
||||||
},
|
},
|
||||||
options = { for k, v in (tcp_connections) do
|
options = {
|
||||||
v = { title = "%di", noarea = true }
|
load__ESTABLISHED = { title = "%di", noarea = true }
|
||||||
end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue