require("luci.util")
require("luci.statistics.datatree")
- -- get rrd data tree
- local tree = luci.statistics.datatree.Instance()
-
-- override entry(): check for existance <plugin>.so where <plugin> is derived from the called path
function _entry( path, ... )
local file = path[5] or path[4]
memory = _("Memory"),
netlink = _("Netlink"),
network = _("Network"),
+ nut = _("UPS"),
olsrd = _("OLSRd"),
ping = _("Ping"),
processes = _("Processes"),
-- create toplevel menu nodes
local st = entry({"admin", "statistics"}, template("admin_statistics/index"), _("Statistics"), 80)
- st.i18n = "statistics"
st.index = true
entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), _("Collectd"), 10).subindex = true
)
e.index = true
- e.i18n = "rrdtool"
for j, plugin in luci.util.vspairs( plugins ) do
_entry(
-- output views
local page = entry( { "admin", "statistics", "graph" }, template("admin_statistics/index"), _("Graphs"), 80)
- page.i18n = "statistics"
page.setuser = "nobody"
page.setgroup = "nogroup"
local vars = luci.http.formvalue(nil, true)
local span = vars.timespan or nil
+ local host = vars.host or nil
+
+ -- get rrd data tree
+ local tree = luci.statistics.datatree.Instance(host)
for i, plugin in luci.util.vspairs( tree:plugins() ) do
entry(
{ "admin", "statistics", "graph", plugin },
call("statistics_render"), labels[plugin], i
- ).query = { timespan = span }
+ ).query = { timespan = span , host = host }
-- if more then one instance is found then generate submenu
if #instances > 1 then
entry(
{ "admin", "statistics", "graph", plugin, inst },
call("statistics_render"), inst, j
- ).query = { timespan = span }
+ ).query = { timespan = span , host = host }
end
end
end
local uci = luci.model.uci.cursor()
local spans = luci.util.split( uci:get( "luci_statistics", "collectd_rrdtool", "RRATimespans" ), "%s+", nil, true )
local span = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
- local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) )
+ local host = vars.host or uci:get( "luci_statistics", "collectd", "Hostname" ) or luci.sys.hostname()
+ local opts = { host = vars.host }
+ local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ), opts )
+ local hosts = graph.tree:host_instances()
local is_index = false
plugin = plugin,
timespans = spans,
current_timespan = span,
+ hosts = hosts,
+ current_host = host,
is_index = is_index
} )
end