luci-app-statistics: cpufreq: changes in data structure
[oweals/luci.git] / applications / luci-app-statistics / luasrc / statistics / rrdtool / definitions / cpufreq.lua
1 -- Licensed to the public under the Apache License 2.0.
2
3 module("luci.statistics.rrdtool.definitions.cpufreq",package.seeall)
4
5 local uci = require("luci.model.uci").cursor()
6 local extraitems = uci:get("luci_statistics", "collectd_cpufreq", "ExtraItems") or nil
7
8 function item()
9         return luci.i18n.translate("CPU Frequency")
10 end
11
12 function rrdargs( graph, plugin, plugin_instance, dtype )
13
14         local cpufreq =  {
15                 title = "%H: Processor frequency - core %pi",
16                 alt_autoscale = true,
17                 vlabel = "Frequency (Hz)",
18                 number_format = "%3.2lf%s",
19                 data = {
20                         types = {"cpufreq" },
21                         options = {
22                                 cpufreq = { color = "ff0000", title = "Frequency" },
23                         }
24                 }
25         }
26
27     if extraitems then
28
29         local transitions = {
30                 title = "%H: Frequency transitions - core %pi",
31                 alt_autoscale = true,
32                 vlabel = "Transitions",
33                 number_format = "%3.2lf%s",
34                 data = {
35                         types = { "transitions" },
36                         options = {
37                                 transitions = { color = "0000ff", title = "Transitions", noarea=true },
38                         }
39                 }
40         }
41
42         local percentage = {
43                 title = "%H: Frequency distribution - core %pi",
44                 alt_autoscale = true,
45                 vlabel = "Frequency (Hz)",
46                 number_format = "%5.2lf%%",
47                 data = {
48                         types = { "percent" },
49                         options = {
50                                 percent = { title = "Frequency %di" },
51                         }
52                 }
53         }
54
55         return { cpufreq, transitions, percentage }
56     else
57         return { cpufreq }
58     end
59 end
60