summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-statistics/luasrc/statistics/rrdtool/definitions/cpufreq.lua
blob: d3596637b22330223f4abf5ea138527b30ccd48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
-- 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 Hz", negweight = true },
			}
		}
	}

	return { cpufreq, transitions, percentage }
    else
	return { cpufreq }
    end
end