summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua4
-rw-r--r--applications/luci-statistics/luasrc/i18n/statistics.en57
-rw-r--r--applications/luci-statistics/luasrc/statistics/i18n.lua100
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool.lua28
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua7
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/interface.lua12
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua5
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua30
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua3
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua3
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua9
-rw-r--r--applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua12
12 files changed, 179 insertions, 91 deletions
diff --git a/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
index 067428b46..871a3585e 100644
--- a/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
+++ b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua
@@ -44,7 +44,7 @@ function index()
-- 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)
@@ -99,7 +99,7 @@ function statistics_render()
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
diff --git a/applications/luci-statistics/luasrc/i18n/statistics.en b/applications/luci-statistics/luasrc/i18n/statistics.en
new file mode 100644
index 000000000..3c7514a47
--- /dev/null
+++ b/applications/luci-statistics/luasrc/i18n/statistics.en
@@ -0,0 +1,57 @@
+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"
diff --git a/applications/luci-statistics/luasrc/statistics/i18n.lua b/applications/luci-statistics/luasrc/statistics/i18n.lua
new file mode 100644
index 000000000..a31d12667
--- /dev/null
+++ b/applications/luci-statistics/luasrc/statistics/i18n.lua
@@ -0,0 +1,100 @@
+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
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-statistics/luasrc/statistics/rrdtool.lua
index 17ac48a5a..1fe57a225 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool.lua
@@ -3,7 +3,7 @@ module("luci.statistics.rrdtool", package.seeall)
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")
@@ -17,7 +17,7 @@ function Graph.__init__( self, timespan, opts )
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)
@@ -34,12 +34,9 @@ function Graph.__init__( self, timespan, opts )
-- 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
@@ -52,11 +49,17 @@ function Graph.mktitle( self, plugin, plugin_instance, dtype, dtype_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 )
@@ -366,7 +369,6 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
-- 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,
@@ -381,6 +383,10 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
} )
+ -- 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()
@@ -415,9 +421,9 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
-- 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
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua
index 5a2ac53ca..bd002e12f 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua
@@ -3,12 +3,9 @@ module("luci.statistics.rrdtool.definitions.cpu.cpu",package.seeall)
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 = {
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/interface.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/interface.lua
index 1b61ad68e..0d812d6ec 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/interface.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/interface.lua
@@ -7,12 +7,6 @@ function rrdargs( graph, host, plugin, plugin_instance )
--
local traffic = {
- -- diagram title
- title = "Verkehr",
-
- -- vertical label
- vlabel = "Bytes/s",
-
-- draw this diagram for each data instance
per_instance = true,
@@ -45,12 +39,6 @@ function rrdargs( graph, host, plugin, plugin_instance )
--
local packets = {
- -- diagram title
- title = "Pakete",
-
- -- vertical label
- vlabel = "Pakete/s",
-
-- draw this diagram for each data instance
per_instance = true,
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua
index 455107322..2ab57e862 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua
@@ -3,10 +3,7 @@ module("luci.statistics.rrdtool.definitions.iptables.ipt_packets", package.seeal
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "Firewall",
- vlabel = "Pakete/s",
-
- data = {
+ data = {
options = {
ipt_packets = { total = true }
}
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua
index 47594f0f8..8f32ab3d1 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua
@@ -7,12 +7,6 @@ function rrdargs( graph, plugin, plugin_instance )
--
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)
@@ -42,12 +36,6 @@ function rrdargs( graph, plugin, plugin_instance )
--
local packets = {
- -- diagram title
- title = "Pakete",
-
- -- vertical label
- vlabel = "Pakete/s",
-
-- diagram data description
data = {
-- data type order
@@ -116,12 +104,6 @@ function rrdargs( graph, plugin, plugin_instance )
--
local multicast = {
- -- diagram title
- title = "Multicast-Pakete",
-
- -- vertical label
- vlabel = "Pakete/s",
-
-- diagram data description
data = {
-- data type order
@@ -144,12 +126,6 @@ function rrdargs( graph, plugin, plugin_instance )
--
local collisions = {
- -- diagram title
- title = "Paketkollisionen",
-
- -- vertical label
- vlabel = "Kollisionen/s",
-
-- diagram data description
data = {
-- data type order
@@ -172,12 +148,6 @@ function rrdargs( graph, plugin, plugin_instance )
--
local errors = {
- -- diagram title
- title = "TX/RX-Fehler",
-
- -- vertical label
- vlabel = "Kollisionen/s",
-
-- diagram data description
data = {
-- data type order
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua
index cf1db00b4..a7bf2956c 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua
@@ -3,9 +3,6 @@ module("luci.statistics.rrdtool.definitions.ping.ping", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "Pingzeiten",
- vlabel = "ms",
-
data = {
sources = {
ping = { "ping" }
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua
index 715d19c76..5dd446f31 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua
@@ -3,9 +3,6 @@ module("luci.statistics.rrdtool.definitions.processes.ps_state", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "Prozesse",
- vlabel = "Anzahl/s",
-
data = {
instances = {
ps_state = {
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua
index c944d990d..7f54c1091 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua
@@ -3,9 +3,6 @@ module("luci.statistics.rrdtool.definitions.tcpconns.tcp_connections", package.s
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
- title = "TCP-Verbindungen auf Port " .. plugin_instance,
- vlabel = "Anzahl/s",
-
data = {
instances = {
tcp_connections = {
@@ -13,12 +10,6 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
"LAST_ACK", "TIME_WAIT", "CLOSING", "CLOSE_WAIT",
"CLOSED", "FIN_WAIT1", "FIN_WAIT2"
}
- },
-
- options = {
- tcp_connections = {
- total = true
- }
}
}
}
diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua
index 6c68bb269..7c0888558 100644
--- a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua
+++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua
@@ -7,12 +7,6 @@ function rrdargs( graph, host, plugin, plugin_instance )
--
local snr = {
- -- diagram title
- title = "Signal / Noise",
-
- -- vertical label
- vlabel = "dBm",
-
-- draw this diagram for each data instance
per_instance = true,
@@ -41,12 +35,6 @@ function rrdargs( graph, host, plugin, plugin_instance )
--
local quality = {
- -- diagram title
- title = "Signalqualitaet",
-
- -- vertical label
- vlabel = "n/5",
-
-- draw this diagram for each data instance
per_instance = true,