applications/luci-statistics: move all models to the per-plugin level, provide titles and labels, provide model for disk plugin

This commit is contained in:
Jo-Philipp Wich 2011-11-28 03:26:59 +00:00
parent ef9df734c3
commit 5d4191c848
16 changed files with 409 additions and 115 deletions

View file

@ -9,15 +9,18 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
$Id: cpu.lua 2274 2008-06-03 23:15:16Z jow $
]]--
module("luci.statistics.rrdtool.definitions.cpu.cpu",package.seeall)
module("luci.statistics.rrdtool.definitions.cpu",package.seeall)
function rrdargs( graph, host, plugin, plugin_instance, dtype )
return {
title = "%H: Processor usage on core #%pi",
vlabel = "Percent",
number_format = "%5.1lf%%",
data = {
instances = {
cpu = { "idle", "user", "system", "nice" }

View file

@ -9,17 +9,19 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
$Id: df.lua 2274 2008-06-03 23:15:16Z jow $
]]--
module("luci.statistics.rrdtool.definitions.df.df", package.seeall)
module("luci.statistics.rrdtool.definitions.df", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
title = "%H: Disk space usage on %di",
vlabel = "Bytes",
per_instance = true,
number_format = "%5.1lf%s",
number_format = "%5.1lf%sB",
data = {
sources = {
@ -28,12 +30,15 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
options = {
df__free = {
color = "00ff00"
color = "00ff00",
overlay = false,
title = "free"
},
df__used = {
color = "ff0000",
flip = true
overlay = false,
title = "used"
}
}
}

View file

@ -0,0 +1,72 @@
--[[
Luci statistics - df plugin diagram definition
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id: df.lua 2274 2008-06-03 23:15:16Z jow $
]]--
module("luci.statistics.rrdtool.definitions.disk", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
{
title = "%H: Disk I/O operations on %pi",
vlabel = "Operations/s",
number_format = "%5.1lf%sOp/s",
data = {
types = { "disk_ops" },
sources = {
disk_ops = { "read", "write" },
},
options = {
disk_ops__read = {
title = "Reads",
color = "00ff00",
flip = false
},
disk_ops__write = {
title = "Writes",
color = "ff0000",
flip = true
}
}
}
},
{
title = "%H: Disk I/O bandwidth on %pi",
vlabel = "Bytes/s",
number_format = "%5.1lf%sB/s",
data = {
types = { "disk_octets" },
sources = {
disk_octets = { "read", "write" }
},
options = {
disk_octets__read = {
title = "Read",
color = "00ff00",
flip = false
},
disk_octets__write = {
title = "Write",
color = "ff0000",
flip = true
}
}
}
}
}
end

View file

@ -24,6 +24,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
-- draw this diagram for each data instance
per_instance = true,
title = "%H: Transfer on %di",
vlabel = "Bytes/s",
-- diagram data description
data = {
@ -36,13 +38,15 @@ function rrdargs( graph, host, plugin, plugin_instance )
options = {
if_octets__tx = {
total = true, -- report total amount of bytes
color = "00ff00" -- tx is green
color = "00ff00", -- tx is green
title = "Bytes (TX)"
},
if_octets__rx = {
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "0000ff" -- rx is blue
color = "0000ff", -- rx is blue
title = "Bytes (RX)"
}
}
}
@ -56,6 +60,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
-- draw this diagram for each data instance
per_instance = true,
title = "%H: Packets on %di",
vlabel = "Packets/s",
-- diagram data description
data = {
@ -74,7 +80,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
if_packets__tx = {
overlay = true, -- don't summarize
total = true, -- report total amount of bytes
color = "00ff00" -- processed tx is green
color = "00ff00", -- processed tx is green
title = "Processed (tx)"
},
-- processed packets (rx DS)
@ -82,14 +89,16 @@ function rrdargs( graph, host, plugin, plugin_instance )
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of bytes
color = "0000ff" -- processed rx is blue
color = "0000ff", -- processed rx is blue
title = "Processed (rx)"
},
-- packet errors (tx DS)
if_errors__tx = {
overlay = true, -- don't summarize
total = true, -- report total amount of packets
color = "ff5500" -- tx errors are orange
color = "ff5500", -- tx errors are orange
title = "Errors (tx)"
},
-- packet errors (rx DS)
@ -97,7 +106,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
overlay = true, -- don't summarize
flip = true, -- flip rx line
total = true, -- report total amount of packets
color = "ff0000" -- rx errors are red
color = "ff0000", -- rx errors are red
title = "Errors (rx)"
}
}
}

View file

@ -0,0 +1,53 @@
--[[
Luci statistics - iptables plugin diagram definition
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id: ipt_bytes.lua 2276 2008-06-03 23:18:37Z jow $
]]--
module("luci.statistics.rrdtool.definitions.iptables", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
{
title = "%H: Firewall: Processed bytes in %pi",
vlabel = "Bytes/s",
number_format = "%5.0lf%sB/s",
totals_format = "%5.0lf%sB",
data = {
types = { "ipt_bytes" },
options = {
ipt_bytes = {
total = true,
title = "%di"
}
}
}
},
{
title = "%H: Firewall: Processed packets in %pi",
vlabel = "Packets/s",
number_format = "%5.1lf P/s",
totals_format = "%5.0lf%s",
data = {
types = { "ipt_packets" },
options = {
ipt_packets = {
total = true,
title = "%di"
}
}
}
}
}
end

View file

@ -1,27 +0,0 @@
--[[
Luci statistics - iptables plugin diagram definition
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
module("luci.statistics.rrdtool.definitions.iptables.ipt_bytes", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
data = {
options = {
ipt_bytes = { total = true }
}
}
}
end

View file

@ -1,27 +0,0 @@
--[[
Luci statistics - iptables plugin diagram definition
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
module("luci.statistics.rrdtool.definitions.iptables.ipt_packets", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
data = {
options = {
ipt_packets = { total = true }
}
}
}
end

View file

@ -9,17 +9,22 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
$Id: irq.lua 2276 2008-06-03 23:18:37Z jow $
]]--
module("luci.statistics.rrdtool.definitions.irq.irq", package.seeall)
module("luci.statistics.rrdtool.definitions.irq", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
data = {
types = { "irq" }
title = "%H: Interrupts", vlabel = "Issues/s",
number_format = "%5.0lf", data = {
types = { "irq" },
options = {
irq = { title = "IRQ %di", noarea = true }
}
}
}
end

View file

@ -9,24 +9,25 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
$Id: load.lua 2329 2008-06-08 21:51:55Z jow $
]]--
module("luci.statistics.rrdtool.definitions.load.load", package.seeall)
module("luci.statistics.rrdtool.definitions.load", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
data = {
title = "%H: Load", vlabel = "Load",
number_format = "%5.2lf", data = {
sources = {
load = { "shortterm", "midterm", "longterm" }
},
options = {
load__shortterm = { color = "ff0000" },
load__midterm = { color = "ff6600" },
load__longterm = { color = "ffaa00" }
load__shortterm = { color = "ff0000", title = "1 minute", noarea = true },
load__midterm = { color = "ff6600", title = "5 minutes", noarea = true },
load__longterm = { color = "ffaa00", title = "15 minutes", noarea = true }
}
}
}

View file

@ -21,6 +21,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- traffic diagram
--
local traffic = {
title = "%H: Netlink - Transfer on %pi",
vlabel = "Bytes/s",
-- diagram data description
data = {
@ -50,6 +52,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- packet diagram
--
local packets = {
title = "%H: Netlink - Packets on %pi",
vlabel = "Packets/s",
-- diagram data description
data = {
@ -118,6 +122,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- multicast diagram
--
local multicast = {
title = "%H: Netlink - Multicast on %pi",
vlabel = "Packets/s",
-- diagram data description
data = {
@ -140,6 +146,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- collision diagram
--
local collisions = {
title = "%H: Netlink - Collisions on %pi",
vlabel = "Collisions/s",
-- diagram data description
data = {
@ -162,6 +170,8 @@ function rrdargs( graph, plugin, plugin_instance )
-- error diagram
--
local errors = {
title = "%H: Netlink - Errors on %pi",
vlabel = "Errors/s",
-- diagram data description
data = {

View file

@ -0,0 +1,153 @@
--[[
Luci statistics - olsrd plugin diagram definition
Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
]]--
module("luci.statistics.rrdtool.definitions.olsrd", package.seeall)
local tree = luci.statistics.datatree.Instance()
function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
local g = { }
if plugin_instance == "routes" then
g[#g+1] = {
-- diagram data description
title = "%H: Total amount of OLSR routes", vlabel = "n",
number_format = "%5.0lf", data = {
types = { "routes" },
options = {
routes = {
color = "ff0000",
title = "Total number of routes"
}
}
}
}
if not is_index then
g[#g+1] = {
title = "%H: Average route ETX", vlabel = "ETX",
number_format = "%5.1lf",data = {
instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
types = { "route_etx" },
options = {
route_etx = {
title = "Average route ETX"
}
}
}
}
g[#g+1] = {
title = "%H: Average route metric", vlabel = "metric",
number_format = "%5.1lf", data = {
instances = { "average" }, -- falls es irgendwann mal welche pro ip gibt, wie bei links, dann werden die hier excludiert
types = { "route_metric" },
options = {
route_metric = {
title = "Average route metric"
}
}
}
}
end
elseif plugin_instance == "links" then
g[#g+1] = {
-- diagram data description
title = "%H: Total amount of OLSR neighbours", vlabel = "n",
number_format = "%5.0lf", data = {
instances = { "" },
types = { "links" },
options = {
links = {
color = "00ff00",
title = "Number of neighbours"
}
}
}
}
if not is_index then
local instances = tree:data_instances(plugin, plugin_instance, "signal_quality")
table.sort(instances)
-- define one diagram per host, containing the rx and lq values
local i
for i = 1, #instances, 2 do
local dsn1 = "signal_quality_%s_value" % instances[i]:gsub("[^%w]+", "_")
local dsn2 = "signal_quality_%s_value" % instances[i+1]:gsub("[^%w]+", "_")
local host = instances[i]:match("^[^%-]+%-([^%-]+)%-.+")
g[#g+1] = {
title = "%H: Signal Quality" .. " (" .. (host or "avg") ..")", vlabel = "ETX",
number_format = "%5.2lf", data = {
types = { "signal_quality" },
instances = {
signal_quality = { instances[i], instances[i+1] },
},
options = {
[dsn1] = {
color = "00ff00",
title = "LQ (%s)" % (host or "avg"),
},
[dsn2] = {
color = "0000ff",
title = "NLQ (%s)" % (host or "avg"),
flip = true
}
}
}
}
end
end
elseif plugin_instance == "topology" then
g[#g+1] = {
title= "%H: Total amount of OLSR links", vlabel = "n",
number_format = "%5.0lf", data = {
instances = { "" },
types = { "links" },
options = {
links = { -- or: links__value is aber egal weils eh nur eines davon gibt
color = "0000ff",
title = "Total number of links"
}
}
}
}
if not is_index then
g[#g+1] = {
title= "%H: Average signal quality", vlabel = "n",
number_format = "%5.2lf", data = {
instances = { "average" }, -- exclude possible per-ip stuff
types = { "signal_quality" },
options = {
signal_quality = {
color = "0000ff",
title = "Average signal quality"
}
}
}
}
end
end
return g
end

View file

@ -0,0 +1,41 @@
--[[
Luci statistics - ping plugin diagram definition
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id: ping.lua 6810 2011-01-29 03:33:48Z jow $
]]--
module("luci.statistics.rrdtool.definitions.ping", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
return {
-- Ping roundtrip time
{ title = "%H: ICMP Round Trip Time", vlabel = "ms",
number_format = "%5.1lf ms", data = {
sources = { ping = { "ping" } },
options = { ping__ping = { noarea = true, title = "%di" } }
} },
-- Ping droprate
{ title = "%H: ICMP Drop Rate", vlabel = "%",
number_format = "%5.2lf %%", data = {
types = { "ping_droprate" },
options = { ping_droprate = { title = "%di" } }
} },
-- Ping standard deviation
{ title = "%H: ICMP Standard Deviation", vlabel = "ms",
number_format = "%5.2lf ms", data = {
types = { "ping_stddev" },
options = { ping_stddev = { title = "%di" } }
} },
}
end

View file

@ -1,27 +0,0 @@
--[[
Luci statistics - ping plugin diagram definition
(c) 2008 Freifunk Leipzig / Jo-Philipp Wich <xm@leipzig.freifunk.net>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
module("luci.statistics.rrdtool.definitions.ping.ping", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
data = {
sources = {
ping = { "ping" }
}
}
}
end

View file

@ -15,10 +15,12 @@ $Id$
module("luci.statistics.rrdtool.definitions.processes", package.seeall)
function rrdargs( graph, plugin, plugin_instance )
function rrdargs( graph, plugin, plugin_instance, dtype, is_index )
if plugin_instance == "" then
if is_index then
return {
title = "%H: Processes",
vlabel = "Processes/s",
data = {
instances = {
ps_state = {
@ -38,8 +40,9 @@ function rrdargs( graph, plugin, plugin_instance )
}
else
return {
{
title = "%H: CPU time used by %pi",
vlabel = "Jiffies",
data = {
sources = {
ps_cputime = { "syst", "user" }
@ -60,6 +63,8 @@ function rrdargs( graph, plugin, plugin_instance )
},
{
title = "%H: Threads and processes belonging to %pi",
vlabel = "Count",
data = {
sources = {
ps_count = { "threads", "processes" }
@ -73,6 +78,8 @@ function rrdargs( graph, plugin, plugin_instance )
},
{
title = "%H: Page faults in %pi",
vlabel = "Pagefaults",
data = {
sources = {
ps_pagefaults = { "minflt", "majflt" }
@ -86,8 +93,9 @@ function rrdargs( graph, plugin, plugin_instance )
},
{
number_format = "%5.1lf%s",
title = "%H: Virtual memory size of %pi",
vlabel = "Bytes",
number_format = "%5.1lf%sB",
data = {
types = { "ps_rss" },

View file

@ -9,21 +9,28 @@ You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
$Id: tcp_connections.lua 2274 2008-06-03 23:15:16Z jow $
]]--
module("luci.statistics.rrdtool.definitions.tcpconns.tcp_connections", package.seeall)
module("luci.statistics.rrdtool.definitions.tcpconns", package.seeall)
function rrdargs( graph, plugin, plugin_instance, dtype )
return {
title = "%H: TCP connections to port %pi",
vlabel = "Connections/s",
number_format = "%5.0lf",
data = {
types = { "tcp_connections" },
instances = {
tcp_connections = {
"SYN_SENT", "SYN_RECV", "LISTEN", "ESTABLISHED",
"LAST_ACK", "TIME_WAIT", "CLOSING", "CLOSE_WAIT",
"CLOSED", "FIN_WAIT1", "FIN_WAIT2"
},
options = { for k, v in (tcp_connections) do
v = { title = "%di", noarea = true }
end
}
}
}

View file

@ -26,6 +26,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
per_instance = true,
-- diagram data description
title = "%H: Signal to Noise Ratio on %pi",
vlabel = "dBm",
data = {
types = { "signal_noise", "signal_power" },
@ -33,12 +35,14 @@ function rrdargs( graph, host, plugin, plugin_instance )
options = {
signal_power = {
overlay = true, -- don't summarize
color = "0000ff" -- power is blue
color = "0000ff", -- power is blue
title = "Signal",
},
signal_noise = {
overlay = true, -- don't summarize
color = "ff0000" -- noise is red
color = "ff0000", -- noise is red
title = "Noise",
}
}
}
@ -52,6 +56,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
-- draw this diagram for each data instance
per_instance = true,
title = "%H: Signal Quality on %pi",
vlabel = "n",
-- diagram data description
data = {
@ -61,7 +67,8 @@ function rrdargs( graph, host, plugin, plugin_instance )
options = {
signal_quality = {
noarea = true, -- don't draw area
color = "0000ff" -- quality is blue
color = "0000ff", -- quality is blue
title = "Signal Quality"
}
}
}