Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / applications / luci-app-statistics / luasrc / statistics / rrdtool / definitions / cpufreq.lua
index bd30ededa0a3f5791b421eeb3e82e4273d9d2169..cb7ae53afa6c76c20bb699ccf90ba24a3458e089 100644 (file)
@@ -2,24 +2,60 @@
 
 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 )
 
-       return {
-               title = "%H: Processor frequency",
+       local cpufreq =  {
+               title = "%H: Processor frequency - core %pi",
                alt_autoscale = true,
                vlabel = "Frequency (Hz)",
                number_format = "%3.2lf%s",
                data = {
-                       instances = {
-                               cpufreq = { "3", "2", "1", "0" }
-                       },
+                       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 = {
-                               cpufreq_0 = { color = "ff0000", title = "Core 0", noarea=true, overlay=true },
-                               cpufreq_1 = { color = "0000ff", title = "Core 1", noarea=true, overlay=true },
-                               cpufreq_2 = { color = "00ff00", title = "Core 2", noarea=true, overlay=true },
-                               cpufreq_3 = { color = "00ffff", title = "Core 3", noarea=true, overlay=true }
+                               percent = { title = "%di kHz", negweight = true },
                        }
                }
        }
+
+       return { cpufreq, percentage, transitions }
+    else
+       return { cpufreq }
+    end
 end