-- public views
- entry({"freifunk", "statistics"}, call("statistics_index"), "Statistiken", 80)
+ entry({"freifunk", "statistics"}, call("statistics_index"), "Statistiken", 80).i18n = "statistics"
for i, plugin in ipairs( data:plugins() ) do
_entry({"freifunk", "statistics", plugin}, call("statistics_render"), plugin, i)
for i, inst in ipairs( data:plugin_instances( plugin ) ) do
local graph = rrd.Graph()
- for i, img in ipairs( graph:render( "OpenWrt", plugin, inst ) ) do
+ for i, img in ipairs( graph:render( plugin, inst ) ) do
table.insert( images, img )
end
end
--- /dev/null
+stat_dg_title_wireless__signal_noise = "%H: Wireless - Signal Noise Ratio"
+stat_dg_label_wireless__signal_noise = "dBm"
+stat_ds_signal_noise = "Noise Level"
+stat_ds_signal_power = "Signal Strength"
+
+stat_dg_title_wireless__signal_quality = "%H: Wireless - Signal Quality"
+stat_dg_label_wireless__signal_quality = "n"
+stat_ds_signal_quality = "Signal Quality"
+
+stat_dg_title_ping = "%H: ICMP Roundtrip Times"
+stat_dg_label_ping = "ms"
+stat_ds_ping = "%di"
+
+stat_dg_title_iptables__ipt_packets = "%H: Firewall - Processed Packets"
+stat_dg_label_iptables__ipt_packets = "Packets/s"
+stat_ds_ipt_packets = 'Chain "%di"'
+
+stat_dg_title_netlink__if_octets = "%H: Netlink - Transfer on %pi"
+stat_dg_label_netlink__if_octets = "Bytes/s"
+stat_ds_if_octets = "Bytes (%ds)"
+
+stat_dg_title_netlink__if_packets = "%H: Netlink - Packets on %pi"
+stat_dg_label_netlink__if_packets = "Packets/s"
+stat_ds_if_packets = "Processed (%ds)"
+stat_ds_if_dropped = "Dropped (%ds)"
+stat_ds_if_errors = "Errors (%ds)"
+
+stat_dg_title_netlink__if_multicast = "%H: Netlink - Multicast on %pi"
+stat_dg_label_netlink__if_multicast = "Packets/s"
+stat_ds_if_multicast = "Packets"
+
+stat_dg_title_netlink__if_collisions = "%H: Netlink - Collisions on %pi"
+stat_dg_label_netlink__if_collisions = "Collisions/s"
+stat_ds_if_collisions = "Collisions"
+
+stat_dg_title_netlink__if_tx_errors = "%H: Netlink - Errors on %pi"
+stat_dg_label_netlink__if_tx_errors = "Errors/s"
+stat_ds_if_tx_errors = "%di"
+stat_ds_if_rx_errors = "%di"
+
+stat_dg_title_processes = "%H: Processes"
+stat_dg_label_processes = "Processes/s"
+stat_ds_ps_state = "%di"
+
+stat_dg_title_cpu = "%H: Usage on Processor #%pi"
+stat_dg_label_cpu = "%"
+stat_ds_cpu = "%di"
+
+stat_dg_title_interface__if_octets = "%H: Transfer on %di"
+stat_dg_label_interface__if_octets = "Bytes/s"
+
+stat_dg_title_interface__if_packets = "%H: Packets on %di"
+stat_dg_label_interface__if_packets = "Packets/s"
+
+stat_dg_title_tcpconns = "%H: TCP-Connections to Port %pi"
+stat_dg_label_tcpconns = "Connections/s"
+stat_ds_tcp_connections = "%di"
--- /dev/null
+module("luci.statistics.i18n", package.seeall)
+
+require("luci.util")
+require("luci.i18n")
+
+
+Instance = luci.util.class()
+
+
+function Instance.__init__( self, graph )
+ self.i18n = luci.i18n
+ self.graph = graph
+
+ -- XXX: compat hack
+ self.i18n.load("statistics.en")
+end
+
+function Instance._subst( self, str, val )
+ str = str:gsub( "%%H", self.graph.opts.host or "" )
+ str = str:gsub( "%%pn", val.plugin or "" )
+ str = str:gsub( "%%pi", val.pinst or "" )
+ str = str:gsub( "%%dt", val.dtype or "" )
+ str = str:gsub( "%%di", val.dinst or "" )
+ str = str:gsub( "%%ds", val.dsrc or "" )
+
+ return str
+end
+
+function Instance.title( self, plugin, pinst, dtype, dinst )
+
+ local title = self.i18n.translate(
+ string.format( "stat_dg_title_%s_%s_%s", plugin, pinst, dtype ),
+ self.i18n.translate(
+ string.format( "stat_dg_title_%s_%s", plugin, pinst ),
+ self.i18n.translate(
+ string.format( "stat_dg_title_%s__%s", plugin, dtype ),
+ self.i18n.translate(
+ string.format( "stat_dg_title_%s", plugin ),
+ self.graph:_mkpath( plugin, pinst, dtype )
+ )
+ )
+ )
+ )
+
+ return self:_subst( title, {
+ plugin = plugin,
+ pinst = pinst,
+ dtype = dtype,
+ dinst = dinst
+ } )
+
+end
+
+function Instance.label( self, plugin, pinst, dtype, dinst )
+
+ local label = self.i18n.translate(
+ string.format( "stat_dg_label_%s_%s_%s", plugin, pinst, dtype ),
+ self.i18n.translate(
+ string.format( "stat_dg_label_%s_%s", plugin, pinst ),
+ self.i18n.translate(
+ string.format( "stat_dg_label_%s__%s", plugin, dtype ),
+ self.i18n.translate(
+ string.format( "stat_dg_label_%s", plugin ),
+ self.graph:_mkpath( plugin, pinst, dtype )
+ )
+ )
+ )
+ )
+
+ return self:_subst( label, {
+ plugin = plugin,
+ pinst = pinst,
+ dtype = dtype,
+ dinst = dinst
+ } )
+
+end
+
+function Instance.ds( self, source )
+
+ local label = self.i18n.translate(
+ string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ),
+ self.i18n.translate(
+ string.format( "stat_ds_%s_%s", source.type, source.instance ),
+ self.i18n.translate(
+ string.format( "stat_ds_label_%s__%s", source.type, source.ds ),
+ self.i18n.translate(
+ string.format( "stat_ds_%s", source.type ),
+ source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds
+ )
+ )
+ )
+ )
+
+ return self:_subst( label, {
+ dtype = source.type,
+ dinst = source.instance,
+ dsrc = source.ds
+ } )
+end
require("luci.statistics.datatree")
require("luci.statistics.rrdtool.colors")
require("luci.statistics.rrdtool.definitions")
-require("luci.i18n")
+require("luci.statistics.i18n")
require("luci.util")
require("luci.fs")
self.colors = luci.statistics.rrdtool.colors.Instance()
self.defs = luci.statistics.rrdtool.definitions.Instance()
self.tree = luci.statistics.datatree.Instance()
- self.i18n = luci.i18n
+ self.i18n = luci.statistics.i18n.Instance( self )
-- options
opts.rrasingle = opts.rrasingle or true -- XXX: fixme (uci)
-- store options
self.opts = opts
-
- -- load language file
- self.i18n.loadc("statistics")
end
-function Graph.mktitle( self, plugin, plugin_instance, dtype, dtype_instance )
+function Graph._mkpath( self, plugin, plugin_instance, dtype, dtype_instance )
local t = self.opts.host .. "/" .. plugin
if type(plugin_instance) == "string" and plugin_instance:len() > 0 then
t = t .. "-" .. plugin_instance
end
function Graph.mkrrdpath( self, ... )
- return string.format( "/tmp/%s.rrd", self:mktitle( ... ) )
+ return string.format( "/tmp/%s.rrd", self:_mkpath( ... ) )
end
function Graph.mkpngpath( self, ... )
- return string.format( "/tmp/rrdimg/%s.png", self:mktitle( ... ) )
+ return string.format( "/tmp/rrdimg/%s.png", self:_mkpath( ... ) )
+end
+
+function Graph.mktitle( self, plugin, plugin_instance, dtype, dtype_instance )
+
+ -- try various strings to retrieve a diagram title from the langfile
+ return "XXX"
end
function Graph._forcelol( self, list )
-- store values
_ti( _sources, {
- title = dsname, -- XXX: fixme i18n (dopts.title || i18n || dname)
rrd = dopts.rrd or self:mkrrdpath( plugin, plugin_instance, dtype, dinst ),
color = dopts.color or self.colors:to_string( self.colors:random() ),
flip = dopts.flip or false,
} )
+ -- generate datasource title
+ _sources[#_sources].title = self.i18n:ds( _sources[#_sources] )
+
+
-- find longest name ...
if _sources[#_sources].title:len() > _longest_name then
_longest_name = _sources[#_sources].title:len()
-- store title and vlabel
-- XXX: i18n
_ti( _args, "-t" )
- _ti( _args, opts.title )
+ _ti( _args, opts.title or self.i18n:title( plugin, plugin_instance, _sources[1].type, instance ) )
_ti( _args, "-v" )
- _ti( _args, opts.vlabel )
+ _ti( _args, opts.vlabel or self.i18n:label( plugin, plugin_instance, _sources[1].type, instance ) )
-- store additional rrd options
if opts.rrdopts then
function rrdargs( graph, host, plugin, plugin_instance, dtype )
return {
- title = "Prozessorauslastung",
- vlabel = "%",
-
data = {
- instances = {
- cpu = { "idle", "nice", "system", "user" }
+ instances = {
+ cpu = { "idle", "user", "system", "nice" }
},
options = {
--
local traffic = {
- -- diagram title
- title = "Verkehr",
-
- -- vertical label
- vlabel = "Bytes/s",
-
-- draw this diagram for each data instance
per_instance = true,
--
local packets = {
- -- diagram title
- title = "Pakete",
-
- -- vertical label
- vlabel = "Pakete/s",
-
-- draw this diagram for each data instance
per_instance = true,
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "Firewall",
- vlabel = "Pakete/s",
-
- data = {
+ data = {
options = {
ipt_packets = { total = true }
}
--
local traffic = {
- -- diagram title
- title = "Verkehr",
-
- -- vertical label
- vlabel = "Bytes/s",
-
-- diagram data description
data = {
-- defined sources for data types, if ommitted assume a single DS named "value" (optional)
--
local packets = {
- -- diagram title
- title = "Pakete",
-
- -- vertical label
- vlabel = "Pakete/s",
-
-- diagram data description
data = {
-- data type order
--
local multicast = {
- -- diagram title
- title = "Multicast-Pakete",
-
- -- vertical label
- vlabel = "Pakete/s",
-
-- diagram data description
data = {
-- data type order
--
local collisions = {
- -- diagram title
- title = "Paketkollisionen",
-
- -- vertical label
- vlabel = "Kollisionen/s",
-
-- diagram data description
data = {
-- data type order
--
local errors = {
- -- diagram title
- title = "TX/RX-Fehler",
-
- -- vertical label
- vlabel = "Kollisionen/s",
-
-- diagram data description
data = {
-- data type order
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "Pingzeiten",
- vlabel = "ms",
-
data = {
sources = {
ping = { "ping" }
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "Prozesse",
- vlabel = "Anzahl/s",
-
data = {
instances = {
ps_state = {
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "TCP-Verbindungen auf Port " .. plugin_instance,
- vlabel = "Anzahl/s",
-
data = {
instances = {
tcp_connections = {
"LAST_ACK", "TIME_WAIT", "CLOSING", "CLOSE_WAIT",
"CLOSED", "FIN_WAIT1", "FIN_WAIT2"
}
- },
-
- options = {
- tcp_connections = {
- total = true
- }
}
}
}
--
local snr = {
- -- diagram title
- title = "Signal / Noise",
-
- -- vertical label
- vlabel = "dBm",
-
-- draw this diagram for each data instance
per_instance = true,
--
local quality = {
- -- diagram title
- title = "Signalqualitaet",
-
- -- vertical label
- vlabel = "n/5",
-
-- draw this diagram for each data instance
per_instance = true,