luci/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/cpufreq.lua
Hannu Nyman 24c0e7ca4c luci-app-statistics: cpufreq: tweak graphs
* Frequency usage percentage stats are by kHz instead of Hz.
  Correct the labels. (Linux natively uses kHz for CPU frequency stats,
  but collectd scales the current frequency stats item to Hz.)

* Show frequency usage percentage graph before the transition counts,
  as it is more descriptive.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2019-08-14 19:00:09 +03:00

61 lines
1.3 KiB
Lua

-- Licensed to the public under the Apache License 2.0.
module("luci.statistics.rrdtool.definitions.cpufreq",package.seeall)
local uci = require("luci.model.uci").cursor()
local extraitems = uci:get("luci_statistics", "collectd_cpufreq", "ExtraItems") or nil
function item()
return luci.i18n.translate("CPU Frequency")
end
function rrdargs( graph, plugin, plugin_instance, dtype )
local cpufreq = {
title = "%H: Processor frequency - core %pi",
alt_autoscale = true,
vlabel = "Frequency (Hz)",
number_format = "%3.2lf%s",
data = {
types = {"cpufreq" },
options = {
cpufreq = { color = "ff0000", title = "Frequency" },
}
}
}
if extraitems then
local transitions = {
title = "%H: Frequency transitions - core %pi",
alt_autoscale = true,
vlabel = "Transitions",
number_format = "%3.2lf%s",
data = {
types = { "transitions" },
options = {
transitions = { color = "0000ff", title = "Transitions", noarea=true },
}
}
}
local percentage = {
title = "%H: Frequency distribution - core %pi",
alt_autoscale = true,
vlabel = "Percent",
number_format = "%5.2lf%%",
ordercolor = true,
data = {
types = { "percent" },
options = {
percent = { title = "%di kHz", negweight = true },
}
}
}
return { cpufreq, percentage, transitions }
else
return { cpufreq }
end
end