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]
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
return rv
end
+
+function Instance.host_instances( self )
+ local hosts_path = fs.glob(self._rrddir..'/*')
+ local hosts = { }
+ k = 1
+ for v in hosts_path do
+ hosts[k] = fs.basename(v)
+ k=k+1
+ end
+
+ return hosts
+end
+
local uci = luci.model.uci.cursor()
local sections = uci:get_all( "luci_statistics" )
- -- helper classes
- self.colors = luci.statistics.rrdtool.colors.Instance()
- self.tree = luci.statistics.datatree.Instance()
- self.i18n = luci.statistics.i18n.Instance( self )
-
-- options
opts.timespan = timespan or sections.rrdtool.default_timespan or 900
opts.rrasingle = opts.rrasingle or ( sections.collectd_rrdtool.RRASingle == "1" )
opts.rrdpath = opts.rrdpath:gsub("/$","")
opts.imgpath = opts.imgpath:gsub("/$","")
+ -- helper classes
+ self.colors = luci.statistics.rrdtool.colors.Instance()
+ self.tree = luci.statistics.datatree.Instance(opts.host)
+ self.i18n = luci.statistics.i18n.Instance( self )
+
-- rrdtool default args
self.args = {
"-a", "PNG",
module("luci.statistics.rrdtool.definitions.conntrack",package.seeall)
-function rrdargs( graph, host, plugin, plugin_instance, dtype )
+function rrdargs( graph, plugin, plugin_instance, dtype )
return {
title = "%H: Conntrack entries",
vlabel = "Count",
module("luci.statistics.rrdtool.definitions.cpu",package.seeall)
-function rrdargs( graph, host, plugin, plugin_instance, dtype )
+function rrdargs( graph, plugin, plugin_instance, dtype )
return {
title = "%H: Processor usage on core #%pi",
module("luci.statistics.rrdtool.definitions.dns", package.seeall)
-function rrdargs( graph, host, plugin, plugin_instance )
+function rrdargs( graph, plugin, plugin_instance )
local traffic = {
title = "%H: DNS traffic", vlabel = "Bit/s",
module("luci.statistics.rrdtool.definitions.interface", package.seeall)
-function rrdargs( graph, host, plugin, plugin_instance )
+function rrdargs( graph, plugin, plugin_instance )
--
-- traffic diagram
module("luci.statistics.rrdtool.definitions.iwinfo", package.seeall)
-function rrdargs( graph, host, plugin, plugin_instance )
+function rrdargs( graph, plugin, plugin_instance )
--
-- signal/noise diagram
module("luci.statistics.rrdtool.definitions.memory",package.seeall)
-function rrdargs( graph, host, plugin, plugin_instance, dtype )
+function rrdargs( graph, plugin, plugin_instance, dtype )
return {
title = "%H: Memory usage",
module("luci.statistics.rrdtool.definitions.olsrd", package.seeall)
-local tree = luci.statistics.datatree.Instance()
-
function rrdargs( graph, plugin, plugin_instance, dtype )
local g = { }
}
}
- local instances = tree:data_instances(plugin, plugin_instance, "signal_quality")
+ local instances = graph.tree:data_instances(plugin, plugin_instance, "signal_quality")
table.sort(instances)
-- define one diagram per host, containing the rx and lq values
<h2><a id="content" name="content"><%:Statistics%></a></h2>
<form action="" method="get">
+ <select name="host">
+ <% for i, host in ipairs(hosts) do %>
+ <option<% if host == current_host then %> selected="selected"<% end %>><%=pcdata(host)%></option>
+ <% end %>
+ </select>
+ <input class="cbi-button cbi-button-apply" type="submit" name="submit" value="<%:Display Host »%>" />
<select name="timespan">
<% for i, span in ipairs(timespans) do %>
<option<% if span == current_timespan then %> selected="selected"<% end %>><%=span%></option>
<% end %>
</select>
- <input type="submit" name="submit" value="<%:Display timespan »%>" />
+ <input class="cbi-button cbi-button-apply" type="submit" name="submit" value="<%:Display timespan »%>" />
</form>
<br />
</div>
<%+footer%>
+
config 'statistics' 'collectd_rrdtool'
option 'enable' '1'
- option 'DataDir' '/tmp'
+ option 'DataDir' '/tmp/rrd'
option 'RRARows' '100'
option 'RRASingle' '1'
option 'RRATimespans' '1hour 1day 1week 1month 1year'
+PACKAGE_luci-app-statistics:collectd-mod-rrdtool \
+PACKAGE_luci-app-statistics:collectd-mod-iwinfo \
+PACKAGE_luci-app-statistics:collectd-mod-interface \
- +PACKAGE_luci-app-statistics:collectd-mod-load))
+ +PACKAGE_luci-app-statistics:collectd-mod-load)) \
+ +PACKAGE_luci-app-statistics:collectd-mod-network))
$(eval $(call application,diag-core,LuCI Diagnostics Tools (Core)))