luci-app-statistics: CPU plugin: hide 'idle', tweak defaults
authorHannu Nyman <hannu.nyman@iki.fi>
Sun, 8 Nov 2020 07:29:03 +0000 (09:29 +0200)
committerHannu Nyman <hannu.nyman@iki.fi>
Sun, 8 Nov 2020 07:29:03 +0000 (09:29 +0200)
* Add functionality to hide the metric of 'idle' state
  from the chart and data table. Many routers are mostly idle,
  and the 98% 'idle' dominates the graph reducing its usefulness.
  Without 'idle', the smaller CPU usage spikes are visible.

* Hide 'idle' by default. Provide config option to show it.
  (note: the option in inside LuCI, and has no impact on actual
   data collection by collectd.)

* Tweak the defaults to use the percentage data by default.
  It makes more sense to average users than jiffies.

* Set the current LuCI defaults also in the config file.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpu.js
applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpu.js
applications/luci-app-statistics/root/etc/config/luci_statistics

index 464b28e8eff1d93d1d400ebaa564d64d6ead80ae..7d0dc9a15a4cbab4725f3bfd2b1fc7ff0140f2a6 100644 (file)
@@ -15,6 +15,8 @@ return baseclass.extend({
                if (plugin_instance != '')
                        title = "%H: Processor usage on core #%pi";
 
+               var show_idle = uci.get("luci_statistics", "collectd_cpu", "ShowIdle") == "1" ? true : false;
+
                if (uci.get("luci_statistics", "collectd_cpu", "ReportByState") == "1") {
                        var cpu = {
                                title: title,
@@ -25,7 +27,7 @@ return baseclass.extend({
                                data: {
                                        instances: {
                                                cpu: [
-                                                       "idle",
+                                                       ...(show_idle ? ["idle"] : []),
                                                        "interrupt",
                                                        "nice",
                                                        "softirq",
@@ -81,7 +83,7 @@ return baseclass.extend({
                                data: {
                                        instances: {
                                                percent: [
-                                                       "idle",
+                                                       ...(show_idle ? ["idle"] : []),
                                                        "interrupt",
                                                        "nice",
                                                        "softirq",
index 7b2963cad221329a3ac538a78985a92f8d342c1a..e013e80cd90784af6a83507a84a43be16a0faf5a 100644 (file)
@@ -23,8 +23,16 @@ return baseclass.extend({
                o.rmempty = false;
                o.depends('enable', '1');
 
+               o = s.option(form.Flag, 'ShowIdle', _('Show Idle state'),
+                       _('Report also the value for the idle metric'));
+               o.default = '0';
+               o.rmempty = false;
+               o.depends({'enable': '1', 'ReportByState': '1'});
+
                o = s.option(form.Flag, 'ValuesPercentage', _('Report in percent'),
                        _('When set to true, we request percentage values'));
+               o.default = '1';
+               o.rmempty = false;
                o.depends({ 'enable': '1', 'ReportByCpu': '1', 'ReportByState': '1' });
        },
 
index 1ab9208c3f1bb1344e6d5f7dbbb06eb3d16241ff..5a2b94b675ee618c045805e0d94b62a4eaa84792 100644 (file)
@@ -67,6 +67,10 @@ config statistics 'collectd_contextswitch'
 
 config statistics 'collectd_cpu'
        option enable '1'
+       option ReportByCpu '1'
+       option ReportByState '1'
+       option ShowIdle '0'
+       option ValuesPercentage '1'
 
 config statistics 'collectd_cpufreq'
        option enable '0'