luci-app-statistics: memory: make hiding 'free' configurable 6584/head
authorHannu Nyman <hannu.nyman@iki.fi>
Mon, 9 Oct 2023 20:16:28 +0000 (23:16 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Mon, 9 Oct 2023 20:16:36 +0000 (23:16 +0300)
Make hiding the 'free' memory configurable.
Set default as disabled, shown in graph which always scales to 100%.

If enabled, the graph scales to actually used memory,
which enables a more detailed view to memory usage.

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

index 9b0d179b0af11bd48b7ed3c07ee76c751ab6d478..960d98c1086c62527533e987625b9670b6c80109 100644 (file)
@@ -5,12 +5,14 @@
 
 'use strict';
 'require baseclass';
+'require uci';
 
 return baseclass.extend({
        title: _('Memory'),
 
        rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
                var p = [];
+               var hide_free = uci.get("luci_statistics", "collectd_memory", "HideFree") == "1" ? true : false;
 
                var memory = {
                        title: "%H: Memory usage",
@@ -21,7 +23,7 @@ return baseclass.extend({
                        data: {
                                instances: {
                                        memory: [
-                                               "free",
+                                               ...(hide_free ? [] : ["free"]),
                                                "buffered",
                                                "cached",
                                                "used"
@@ -58,7 +60,7 @@ return baseclass.extend({
                        data: {
                                instances: {
                                        percent: [
-                                               "free",
+                                               ...(hide_free ? [] : ["free"]),
                                                "buffered",
                                                "cached",
                                                "used"
index a4a8eb2761fc6d6c8dd174ca7acb3a344aab130c..864857faa37fbbb66eb2bf557a88f4f4530f6df1 100644 (file)
@@ -11,6 +11,11 @@ return baseclass.extend({
 
                o = s.option(form.Flag, 'enable', _('Enable this plugin'));
 
+               o = s.option(form.Flag, 'HideFree', _('Hide free memory'),
+                       _('Hiding the free memory item makes the graph to scale to actual memory usage, not to 100%.'));
+               o.default = '0';
+               o.rmempty = false;
+
                o = s.option(form.Flag, 'ValuesAbsolute', _('Absolute values'), _('When set to true, we request absolute values'));
                o.default = '1';
                o.depends('enable', '1');
index 2008a7966a585266a29a080ae06577e47429574c..f7783d73f30bb136d4fe0fc8a1f55be3c6ddfae2 100644 (file)
@@ -158,6 +158,7 @@ config statistics 'collectd_load'
 
 config statistics 'collectd_memory'
        option enable '1'
+       option HideFree '0'
        option ValuesAbsolute '1'
        option ValuesPercentage '0'