Merge pull request #3063 from TDT-AG/pr/20190908-luci-app-statistics
luci-app-statistics: Add new plugin options
This commit is contained in:
commit
0d06e3432b
7 changed files with 326 additions and 60 deletions
|
@ -12,4 +12,25 @@ s = m:section( NamedSection, "collectd_cpu", "luci_statistics" )
|
||||||
enable = s:option( Flag, "enable", translate("Enable this plugin") )
|
enable = s:option( Flag, "enable", translate("Enable this plugin") )
|
||||||
enable.default = 0
|
enable.default = 0
|
||||||
|
|
||||||
|
-- collectd_cpu.reportbycpu (ReportByCpu)
|
||||||
|
reportbycpu = s:option( Flag, "ReportByCpu",
|
||||||
|
translate("Report by CPU"),
|
||||||
|
translate("By setting this, CPU is not aggregate of all processors on the system"))
|
||||||
|
reportbycpu.default = 1
|
||||||
|
reportbycpu:depends( "enable", 1 )
|
||||||
|
|
||||||
|
-- collectd_cpu.reportbystate (ReportByState)
|
||||||
|
reportbystate = s:option( Flag, "ReportByState",
|
||||||
|
translate("Report by state"),
|
||||||
|
translate("When set to true, reports per-state metric (system, user, idle)"))
|
||||||
|
reportbystate.default = 1
|
||||||
|
reportbystate:depends( "enable", 1 )
|
||||||
|
|
||||||
|
-- collectd_cpu.valuespercentage (ValuesPercentage)
|
||||||
|
valuespercentage = s:option( Flag, "ValuesPercentage",
|
||||||
|
translate("Report in percent"),
|
||||||
|
translate("When set to true, we request percentage values"))
|
||||||
|
valuespercentage.default = 0
|
||||||
|
valuespercentage:depends({ enable = 1, ReportByCpu = 1, ReportByState = 1 })
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
|
@ -10,4 +10,18 @@ s = m:section( NamedSection, "collectd_memory", "luci_statistics" )
|
||||||
enable = s:option( Flag, "enable", translate("Enable this plugin") )
|
enable = s:option( Flag, "enable", translate("Enable this plugin") )
|
||||||
enable.default = 0
|
enable.default = 0
|
||||||
|
|
||||||
|
-- collectd_memory.valuesabsolute (ValuesAbsolute)
|
||||||
|
valuespercentage = s:option( Flag, "ValuesAbsolute",
|
||||||
|
translate("Absolute values"),
|
||||||
|
translate("When set to true, we request absolute values"))
|
||||||
|
valuespercentage.default = 1
|
||||||
|
valuespercentage:depends( "enable", 1 )
|
||||||
|
|
||||||
|
-- collectd_memory.valuespercentage (ValuesPercentage)
|
||||||
|
valuespercentage = s:option( Flag, "ValuesPercentage",
|
||||||
|
translate("Percent values"),
|
||||||
|
translate("When set to true, we request percentage values"))
|
||||||
|
valuespercentage.default = 0
|
||||||
|
valuespercentage:depends( "enable", 1 )
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
return {
|
return {
|
||||||
legend = {
|
legend = {
|
||||||
{ },
|
{ },
|
||||||
{ },
|
{ "ValuesPercentage" , "ReportByCpu", "ReportByState" },
|
||||||
{ }
|
{ }
|
||||||
},
|
},
|
||||||
label = _("Processor"),
|
label = _("Processor"),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
return {
|
return {
|
||||||
legend = {
|
legend = {
|
||||||
{ },
|
{ },
|
||||||
{ },
|
{ "ValuesPercentage", "ValuesAbsolute" },
|
||||||
{ }
|
{ }
|
||||||
},
|
},
|
||||||
label = _("Memory"),
|
label = _("Memory"),
|
||||||
|
|
|
@ -3,33 +3,167 @@
|
||||||
|
|
||||||
module("luci.statistics.rrdtool.definitions.cpu",package.seeall)
|
module("luci.statistics.rrdtool.definitions.cpu",package.seeall)
|
||||||
|
|
||||||
|
local uci = require("luci.model.uci").cursor()
|
||||||
|
local reportbystate = uci:get("luci_statistics", "collectd_cpu", "ReportByState") or "0"
|
||||||
|
|
||||||
function item()
|
function item()
|
||||||
return luci.i18n.translate("Processor")
|
return luci.i18n.translate("Processor")
|
||||||
end
|
end
|
||||||
|
|
||||||
function rrdargs( graph, plugin, plugin_instance, dtype )
|
function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
|
local p = {}
|
||||||
|
|
||||||
return {
|
local title = "%H: Processor usage"
|
||||||
title = "%H: Processor usage on core #%pi",
|
if #plugin_instance > 0 then
|
||||||
|
title = "%H: Processor usage on core #%pi"
|
||||||
|
end
|
||||||
|
|
||||||
|
if reportbystate == "1" then
|
||||||
|
local cpu = {
|
||||||
|
title = title,
|
||||||
|
y_min = "0",
|
||||||
|
alt_autoscale_max = true,
|
||||||
|
vlabel = "Jiffies",
|
||||||
|
number_format = "%5.1lf",
|
||||||
|
data = {
|
||||||
|
instances = {
|
||||||
|
cpu = {
|
||||||
|
"idle",
|
||||||
|
"interrupt",
|
||||||
|
"nice",
|
||||||
|
"softirq",
|
||||||
|
"steal",
|
||||||
|
"system",
|
||||||
|
"user",
|
||||||
|
"wait"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
cpu_idle = {
|
||||||
|
color = "ffffff",
|
||||||
|
title = "Idle"
|
||||||
|
},
|
||||||
|
cpu_interrupt = {
|
||||||
|
color = "a000a0",
|
||||||
|
title = "Interrupt"
|
||||||
|
},
|
||||||
|
cpu_nice = {
|
||||||
|
color = "00e000",
|
||||||
|
title = "Nice"
|
||||||
|
},
|
||||||
|
cpu_softirq = {
|
||||||
|
color = "ff00ff",
|
||||||
|
title = "Softirq"
|
||||||
|
},
|
||||||
|
cpu_steal = {
|
||||||
|
color = "000000",
|
||||||
|
title = "Steal"
|
||||||
|
},
|
||||||
|
cpu_system = {
|
||||||
|
color = "ff0000",
|
||||||
|
title = "System"
|
||||||
|
},
|
||||||
|
cpu_user = {
|
||||||
|
color = "0000ff",
|
||||||
|
title = "User"
|
||||||
|
},
|
||||||
|
cpu_wait = {
|
||||||
|
color = "ffb000",
|
||||||
|
title = "Wait"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local percent = {
|
||||||
|
title = title,
|
||||||
y_min = "0",
|
y_min = "0",
|
||||||
alt_autoscale_max = true,
|
alt_autoscale_max = true,
|
||||||
vlabel = "Percent",
|
vlabel = "Percent",
|
||||||
number_format = "%5.1lf%%",
|
number_format = "%5.1lf%%",
|
||||||
data = {
|
data = {
|
||||||
instances = {
|
instances = {
|
||||||
cpu = { "user", "nice", "system", "softirq", "interrupt" }
|
percent = {
|
||||||
|
"idle",
|
||||||
|
"interrupt",
|
||||||
|
"nice",
|
||||||
|
"softirq",
|
||||||
|
"steal",
|
||||||
|
"system",
|
||||||
|
"user",
|
||||||
|
"wait"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
cpu_idle = { color = "ffffff", title = "Idle" },
|
percent_idle = {
|
||||||
cpu_nice = { color = "00e000", title = "Nice" },
|
color = "ffffff",
|
||||||
cpu_user = { color = "0000ff", title = "User" },
|
title = "Idle"
|
||||||
cpu_wait = { color = "ffb000", title = "Wait" },
|
},
|
||||||
cpu_system = { color = "ff0000", title = "System" },
|
percent_interrupt = {
|
||||||
cpu_softirq = { color = "ff00ff", title = "Softirq" },
|
color = "a000a0",
|
||||||
cpu_interrupt = { color = "a000a0", title = "Interrupt" },
|
title = "Interrupt"
|
||||||
cpu_steal = { color = "000000", title = "Steal" }
|
},
|
||||||
|
percent_nice = {
|
||||||
|
color = "00e000",
|
||||||
|
title = "Nice"
|
||||||
|
},
|
||||||
|
percent_softirq = {
|
||||||
|
color = "ff00ff",
|
||||||
|
title = "Softirq"
|
||||||
|
},
|
||||||
|
percent_steal = {
|
||||||
|
color = "000000",
|
||||||
|
title = "Steal"
|
||||||
|
},
|
||||||
|
percent_system = {
|
||||||
|
color = "ff0000",
|
||||||
|
title = "System"
|
||||||
|
},
|
||||||
|
percent_user = {
|
||||||
|
color = "0000ff",
|
||||||
|
title = "User"
|
||||||
|
},
|
||||||
|
percent_wait = {
|
||||||
|
color = "ffb000",
|
||||||
|
title = "Wait"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local types = graph.tree:data_types( plugin, plugin_instance )
|
||||||
|
|
||||||
|
for _, t in ipairs(types) do
|
||||||
|
if t == "cpu" then
|
||||||
|
p[#p+1] = cpu
|
||||||
|
end
|
||||||
|
|
||||||
|
if t == "percent" then
|
||||||
|
p[#p+1] = percent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
p = {
|
||||||
|
title = title,
|
||||||
|
y_min = "0",
|
||||||
|
alt_autoscale_max = true,
|
||||||
|
vlabel = "Percent",
|
||||||
|
number_format = "%5.1lf%%",
|
||||||
|
data = {
|
||||||
|
instances = {
|
||||||
|
percent = {
|
||||||
|
"active",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
percent_active = {
|
||||||
|
color = "00e000",
|
||||||
|
title = "Active"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return p
|
||||||
|
end
|
||||||
|
|
|
@ -1,13 +1,5 @@
|
||||||
--[[
|
-- Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
|
||||||
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
(c) 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.memory",package.seeall)
|
module("luci.statistics.rrdtool.definitions.memory",package.seeall)
|
||||||
|
|
||||||
|
@ -16,8 +8,9 @@ function item()
|
||||||
end
|
end
|
||||||
|
|
||||||
function rrdargs( graph, plugin, plugin_instance, dtype )
|
function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
|
local p = {}
|
||||||
|
|
||||||
return {
|
local memory = {
|
||||||
title = "%H: Memory usage",
|
title = "%H: Memory usage",
|
||||||
vlabel = "MB",
|
vlabel = "MB",
|
||||||
number_format = "%5.1lf%s",
|
number_format = "%5.1lf%s",
|
||||||
|
@ -25,15 +18,82 @@ function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
alt_autoscale_max = true,
|
alt_autoscale_max = true,
|
||||||
data = {
|
data = {
|
||||||
instances = {
|
instances = {
|
||||||
memory = { "free", "buffered", "cached", "used" }
|
memory = {
|
||||||
|
"free",
|
||||||
|
"buffered",
|
||||||
|
"cached",
|
||||||
|
"used"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
memory_buffered = { color = "0000ff", title = "Buffered" },
|
memory_buffered = {
|
||||||
memory_cached = { color = "ff00ff", title = "Cached" },
|
color = "0000ff",
|
||||||
memory_used = { color = "ff0000", title = "Used" },
|
title = "Buffered"
|
||||||
memory_free = { color = "00ff00", title = "Free" }
|
},
|
||||||
|
memory_cached = {
|
||||||
|
color = "ff00ff",
|
||||||
|
title = "Cached"
|
||||||
|
},
|
||||||
|
memory_used = {
|
||||||
|
color = "ff0000",
|
||||||
|
title = "Used"
|
||||||
|
},
|
||||||
|
memory_free = {
|
||||||
|
color = "00ff00",
|
||||||
|
title = "Free"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local percent = {
|
||||||
|
title = "%H: Memory usage",
|
||||||
|
vlabel = "Percent",
|
||||||
|
number_format = "%5.1lf%%",
|
||||||
|
y_min = "0",
|
||||||
|
alt_autoscale_max = true,
|
||||||
|
data = {
|
||||||
|
instances = {
|
||||||
|
percent = {
|
||||||
|
"free",
|
||||||
|
"buffered",
|
||||||
|
"cached",
|
||||||
|
"used"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
percent_buffered = {
|
||||||
|
color = "0000ff",
|
||||||
|
title = "Buffered"
|
||||||
|
},
|
||||||
|
percent_cached = {
|
||||||
|
color = "ff00ff",
|
||||||
|
title = "Cached"
|
||||||
|
},
|
||||||
|
percent_used = {
|
||||||
|
color = "ff0000",
|
||||||
|
title = "Used"
|
||||||
|
},
|
||||||
|
percent_free = {
|
||||||
|
color = "00ff00",
|
||||||
|
title = "Free"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local types = graph.tree:data_types( plugin, plugin_instance )
|
||||||
|
|
||||||
|
for _, t in ipairs(types) do
|
||||||
|
if t == "percent" then
|
||||||
|
p[#p+1] = percent
|
||||||
|
end
|
||||||
|
|
||||||
|
if t == "memory" then
|
||||||
|
p[#p+1] = memory
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return p
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,25 +9,62 @@ end
|
||||||
|
|
||||||
function rrdargs( graph, plugin, plugin_instance, dtype )
|
function rrdargs( graph, plugin, plugin_instance, dtype )
|
||||||
|
|
||||||
return {
|
local ping = {
|
||||||
-- Ping roundtrip time
|
title = "%H: ICMP Round Trip Time",
|
||||||
{ title = "%H: ICMP Round Trip Time",
|
|
||||||
vlabel = "ms",
|
vlabel = "ms",
|
||||||
number_format = "%5.1lf ms",
|
number_format = "%5.1lf ms",
|
||||||
data = {
|
data = {
|
||||||
sources = { ping = { "value" } },
|
sources = {
|
||||||
options = { ping__value = {
|
ping = {
|
||||||
noarea = true, overlay = true, title = "%di" } }
|
"value"
|
||||||
} },
|
}
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
ping__value = {
|
||||||
|
noarea = true,
|
||||||
|
overlay = true,
|
||||||
|
title = "%di"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Ping droprate
|
local droprate = {
|
||||||
{ title = "%H: ICMP Drop Rate",
|
title = "%H: ICMP Drop Rate",
|
||||||
vlabel = "%",
|
vlabel = "%",
|
||||||
number_format = "%5.2lf %%",
|
number_format = "%5.2lf %%",
|
||||||
data = {
|
data = {
|
||||||
types = { "ping_droprate" },
|
types = {
|
||||||
options = { ping_droprate = {
|
"ping_droprate"
|
||||||
noarea = true, overlay = true, title = "%di", transform_rpn = "100,*" } }
|
},
|
||||||
} }
|
options = {
|
||||||
|
ping_droprate = {
|
||||||
|
noarea = true,
|
||||||
|
overlay = true,
|
||||||
|
title = "%di",
|
||||||
|
transform_rpn = "100,*"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local stddev = {
|
||||||
|
title = "%H: ICMP Standard Deviation",
|
||||||
|
vlabel = "ms",
|
||||||
|
number_format = "%5.1lf ms",
|
||||||
|
data = {
|
||||||
|
types = {
|
||||||
|
"ping_stddev"
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
ping_stddev = {
|
||||||
|
noarea = true,
|
||||||
|
overlay = true,
|
||||||
|
title = "%di"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { ping, droprate, stddev }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue