luci-app-statistics: add new cpu plugin options
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
parent
6482e48ac6
commit
2be8aefe7f
3 changed files with 176 additions and 21 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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
return {
|
return {
|
||||||
legend = {
|
legend = {
|
||||||
{ },
|
{ },
|
||||||
{ },
|
{ "ValuesPercentage" , "ReportByCpu", "ReportByState" },
|
||||||
{ }
|
{ }
|
||||||
},
|
},
|
||||||
label = _("Processor"),
|
label = _("Processor"),
|
||||||
|
|
|
@ -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
|
||||||
y_min = "0",
|
title = "%H: Processor usage on core #%pi"
|
||||||
alt_autoscale_max = true,
|
end
|
||||||
vlabel = "Percent",
|
|
||||||
number_format = "%5.1lf%%",
|
|
||||||
data = {
|
|
||||||
instances = {
|
|
||||||
cpu = { "user", "nice", "system", "softirq", "interrupt" }
|
|
||||||
},
|
|
||||||
|
|
||||||
options = {
|
if reportbystate == "1" then
|
||||||
cpu_idle = { color = "ffffff", title = "Idle" },
|
local cpu = {
|
||||||
cpu_nice = { color = "00e000", title = "Nice" },
|
title = title,
|
||||||
cpu_user = { color = "0000ff", title = "User" },
|
y_min = "0",
|
||||||
cpu_wait = { color = "ffb000", title = "Wait" },
|
alt_autoscale_max = true,
|
||||||
cpu_system = { color = "ff0000", title = "System" },
|
vlabel = "Jiffies",
|
||||||
cpu_softirq = { color = "ff00ff", title = "Softirq" },
|
number_format = "%5.1lf",
|
||||||
cpu_interrupt = { color = "a000a0", title = "Interrupt" },
|
data = {
|
||||||
cpu_steal = { color = "000000", title = "Steal" }
|
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",
|
||||||
|
alt_autoscale_max = true,
|
||||||
|
vlabel = "Percent",
|
||||||
|
number_format = "%5.1lf%%",
|
||||||
|
data = {
|
||||||
|
instances = {
|
||||||
|
percent = {
|
||||||
|
"idle",
|
||||||
|
"interrupt",
|
||||||
|
"nice",
|
||||||
|
"softirq",
|
||||||
|
"steal",
|
||||||
|
"system",
|
||||||
|
"user",
|
||||||
|
"wait"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
options = {
|
||||||
|
percent_idle = {
|
||||||
|
color = "ffffff",
|
||||||
|
title = "Idle"
|
||||||
|
},
|
||||||
|
percent_interrupt = {
|
||||||
|
color = "a000a0",
|
||||||
|
title = "Interrupt"
|
||||||
|
},
|
||||||
|
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
|
||||||
|
|
||||||
|
return p
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue