summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/luasrc/statistics
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-statistics/luasrc/statistics')
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/i18n.lua30
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool.lua7
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/interface.lua12
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua40
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/nut.lua6
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/openvpn.lua48
-rw-r--r--applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/sensors.lua24
7 files changed, 124 insertions, 43 deletions
diff --git a/applications/luci-app-statistics/luasrc/statistics/i18n.lua b/applications/luci-app-statistics/luasrc/statistics/i18n.lua
index 5a2800d5f4..7877e61ab3 100644
--- a/applications/luci-app-statistics/luasrc/statistics/i18n.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/i18n.lua
@@ -26,15 +26,6 @@ function Instance._subst( self, str, val )
return str
end
-function Instance._translate( self, key, alt )
- local val = self.i18n.string(key)
- if val ~= key then
- return val
- else
- return alt
- end
-end
-
function Instance.title( self, plugin, pinst, dtype, dinst, user_title )
local title = user_title or
@@ -73,24 +64,17 @@ end
function Instance.ds( self, source )
- local label = source.title or self:_translate(
- string.format( "stat_ds_%s_%s_%s", source.type, source.instance, source.ds ),
- self:_translate(
- string.format( "stat_ds_%s_%s", source.type, source.instance ),
- self:_translate(
- string.format( "stat_ds_label_%s__%s", source.type, source.ds ),
- self:_translate(
- string.format( "stat_ds_%s", source.type ),
- source.type .. "_" .. source.instance:gsub("[^%w]","_") .. "_" .. source.ds
- )
- )
- )
- )
+ local label = source.title or
+ "dt=%s/di=%s/ds=%s" % {
+ (source.type and #source.type > 0) and source.type or "(nil)",
+ (source.instance and #source.instance > 0) and source.instance or "(nil)",
+ (source.ds and #source.ds > 0) and source.ds or "(nil)"
+ }
return self:_subst( label, {
dtype = source.type,
dinst = source.instance,
dsrc = source.ds
- } )
+ } ):gsub(":", "\\:")
end
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
index d8317a8177..5d4ad9859d 100644
--- a/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool.lua
@@ -397,6 +397,7 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
transform_rpn = dopts.transform_rpn or "0,+",
noarea = dopts.noarea or false,
title = dopts.title or nil,
+ weight = dopts.weight or nil,
ds = dsource,
type = dtype,
instance = dinst,
@@ -469,6 +470,12 @@ function Graph._generic( self, opts, plugin, plugin_instance, dtype, index )
for i, o in ipairs(opts.rrdopts) do _ti( _args, o ) end
end
+ -- sort sources
+ table.sort(_sources, function(a, b)
+ local x = a.weight or a.index or 0
+ local y = b.weight or b.index or 0
+ return x < y
+ end)
-- create DEF statements for each instance
for i, source in ipairs(_sources) do
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/interface.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/interface.lua
index efa631d557..6f687d218d 100644
--- a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/interface.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/interface.lua
@@ -66,36 +66,40 @@ function rrdargs( graph, plugin, plugin_instance )
options = {
-- processed packets (tx DS)
if_packets__tx = {
+ weight = 1,
overlay = true, -- don't summarize
total = true, -- report total amount of bytes
color = "00ff00", -- processed tx is green
- title = "Processed (tx)"
+ title = "Processed (TX)"
},
-- processed packets (rx DS)
if_packets__rx = {
+ weight = 2,
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "0000ff", -- processed rx is blue
- title = "Processed (rx)"
+ title = "Processed (RX)"
},
-- packet errors (tx DS)
if_errors__tx = {
+ weight = 0,
overlay = true, -- don't summarize
total = true, -- report total amount of packets
color = "ff5500", -- tx errors are orange
- title = "Errors (tx)"
+ title = "Errors (TX)"
},
-- packet errors (rx DS)
if_errors__rx = {
+ weight = 3,
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of packets
color = "ff0000", -- rx errors are red
- title = "Errors (rx)"
+ title = "Errors (RX)"
}
}
}
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua
index b4f2ac185e..7b6acf3663 100644
--- a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua
@@ -22,11 +22,13 @@ function rrdargs( graph, plugin, plugin_instance )
-- special options for single data lines
options = {
if_octets__tx = {
+ title = "Bytes (TX)",
total = true, -- report total amount of bytes
color = "00ff00" -- tx is green
},
if_octets__rx = {
+ title = "Bytes (RX)",
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "0000ff" -- rx is blue
@@ -59,6 +61,8 @@ function rrdargs( graph, plugin, plugin_instance )
options = {
-- processed packets (tx DS)
if_packets__tx = {
+ weight = 2,
+ title = "Total (TX)",
overlay = true, -- don't summarize
total = true, -- report total amount of bytes
color = "00ff00" -- processed tx is green
@@ -66,6 +70,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- processed packets (rx DS)
if_packets__rx = {
+ weight = 3,
+ title = "Total (RX)",
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of bytes
@@ -74,6 +80,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- dropped packets (tx DS)
if_dropped__tx = {
+ weight = 1,
+ title = "Dropped (TX)",
overlay = true, -- don't summarize
total = true, -- report total amount of bytes
color = "660055" -- dropped tx is ... dunno ;)
@@ -81,14 +89,18 @@ function rrdargs( graph, plugin, plugin_instance )
-- dropped packets (rx DS)
if_dropped__rx = {
+ weight = 4,
+ title = "Dropped (RX)",
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of bytes
- color = "440066" -- dropped rx is violett
+ color = "ff00ff" -- dropped rx is violett
},
-- packet errors (tx DS)
if_errors__tx = {
+ weight = 0,
+ title = "Errors (TX)",
overlay = true, -- don't summarize
total = true, -- report total amount of packets
color = "ff5500" -- tx errors are orange
@@ -96,6 +108,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- packet errors (rx DS)
if_errors__rx = {
+ weight = 5,
+ title = "Errors (RX)",
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of packets
@@ -122,6 +136,7 @@ function rrdargs( graph, plugin, plugin_instance )
options = {
-- multicast packets
if_multicast = {
+ title = "Packets",
total = true, -- report total amount of packets
color = "0000ff" -- multicast is blue
}
@@ -146,6 +161,7 @@ function rrdargs( graph, plugin, plugin_instance )
options = {
-- collision rate
if_collisions = {
+ title = "Collisions",
total = true, -- report total amount of packets
color = "ff0000" -- collsions are red
}
@@ -173,15 +189,19 @@ function rrdargs( graph, plugin, plugin_instance )
},
-- special options for single data lines
- options = { -- XXX: fixme (define colors...)
- if_tx_errors = {
- total = true
- },
-
- if_rx_errors = {
- flip = true,
- total = true
- }
+ options = {
+ if_tx_errors_aborted_value = { total = true, color = "ffff00", title = "Aborted (TX)" },
+ if_tx_errors_carrier_value = { total = true, color = "ffcc00", title = "Carrier (TX)" },
+ if_tx_errors_fifo_value = { total = true, color = "ff9900", title = "Fifo (TX)" },
+ if_tx_errors_heartbeat_value = { total = true, color = "ff6600", title = "Heartbeat (TX)" },
+ if_tx_errors_window_value = { total = true, color = "ff3300", title = "Window (TX)" },
+
+ if_rx_errors_length_value = { flip = true, total = true, color = "ff0000", title = "Length (RX)" },
+ if_rx_errors_missed_value = { flip = true, total = true, color = "ff0033", title = "Missed (RX)" },
+ if_rx_errors_over_value = { flip = true, total = true, color = "ff0066", title = "Over (RX)" },
+ if_rx_errors_crc_value = { flip = true, total = true, color = "ff0099", title = "CRC (RX)" },
+ if_rx_errors_fifo_value = { flip = true, total = true, color = "ff00cc", title = "Fifo (RX)" },
+ if_rx_errors_frame_value = { flip = true, total = true, color = "ff00ff", title = "Frame (RX)" }
}
}
}
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/nut.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/nut.lua
index 6dc81bc1d7..8b04ab8b38 100644
--- a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/nut.lua
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/nut.lua
@@ -44,9 +44,6 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
y_max = "100",
number_format = "%5.1lf%%",
data = {
- sources = {
- percent = { "percent" }
- },
instances = {
percent = "charge"
},
@@ -77,9 +74,6 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
vlabel = "Minutes",
number_format = "%.1lfm",
data = {
- sources = {
- timeleft = { "timeleft" }
- },
instances = {
timeleft = { "battery" }
},
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/openvpn.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/openvpn.lua
new file mode 100644
index 0000000000..876e871d1d
--- /dev/null
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/openvpn.lua
@@ -0,0 +1,48 @@
+-- Copyright 2015 Jo-Philipp Wich <jow@openwrt.org>
+-- Licensed to the public under the Apache License 2.0.
+
+module("luci.statistics.rrdtool.definitions.openvpn", package.seeall)
+
+function rrdargs( graph, plugin, plugin_instance )
+ local inst = plugin_instance:gsub("^openvpn%.(.+)%.status$", "%1")
+
+ return {
+ {
+ title = "%%H: OpenVPN \"%s\" - Traffic" % inst,
+ vlabel = "Bytes/s",
+ data = {
+ instances = {
+ if_octets = { "traffic", "overhead" }
+ },
+ sources = {
+ if_octets = { "tx", "rx" }
+ },
+ options = {
+ if_octets_traffic_tx = { weight = 0, title = "Bytes (TX)", total = true, color = "00ff00" },
+ if_octets_overhead_tx = { weight = 1, title = "Overhead (TX)", total = true, color = "ff9900" },
+ if_octets_overhead_rx = { weight = 2, title = "Overhead (RX)", total = true, flip = true, color = "ff00ff" },
+ if_octets_traffic_rx = { weight = 3, title = "Bytes (RX)", total = true, flip = true, color = "0000ff" }
+ }
+ }
+ },
+
+ {
+ title = "%%H: OpenVPN \"%s\" - Compression" % inst,
+ vlabel = "Bytes/s",
+ data = {
+ instances = {
+ compression = { "data_out", "data_in" }
+ },
+ sources = {
+ compression = { "uncompressed", "compressed" }
+ },
+ options = {
+ compression_data_out_uncompressed = { weight = 0, title = "Uncompressed (TX)", total = true, color = "00ff00" },
+ compression_data_out_compressed = { weight = 1, title = "Compressed (TX)", total = true, color = "008800" },
+ compression_data_in_compressed = { weight = 2, title = "Compressed (RX)", total = true, flip = true, color = "000088" },
+ compression_data_in_uncompressed = { weight = 3, title = "Uncompressed (RX)", total = true, flip = true, color = "0000ff" }
+ }
+ }
+ }
+ }
+end
diff --git a/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/sensors.lua b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/sensors.lua
new file mode 100644
index 0000000000..f8bddb96e3
--- /dev/null
+++ b/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/sensors.lua
@@ -0,0 +1,24 @@
+-- Copyright 2015 Jo-Philipp Wich <jow@openwrt.org>
+-- Licensed to the public under the Apache License 2.0.
+
+module("luci.statistics.rrdtool.definitions.sensors", package.seeall)
+
+function rrdargs( graph, plugin, plugin_instance )
+ return {
+ {
+ per_instance = true,
+ title = "%H: %pi - %di",
+ vlabel = "\176C",
+ number_format = "%4.1lf\176C",
+ data = {
+ types = { "temperature" },
+ options = {
+ temperature__value = {
+ color = "ff0000",
+ title = "Temperature"
+ }
+ }
+ }
+ }
+ }
+end