luci-app-statistics: memory: make hiding 'free' configurable

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>
This commit is contained in:
Hannu Nyman 2023-10-09 23:16:28 +03:00
parent f235491381
commit 08540c4462
3 changed files with 10 additions and 2 deletions

View file

@ -5,12 +5,14 @@
'use strict'; 'use strict';
'require baseclass'; 'require baseclass';
'require uci';
return baseclass.extend({ return baseclass.extend({
title: _('Memory'), title: _('Memory'),
rrdargs: function(graph, host, plugin, plugin_instance, dtype) { rrdargs: function(graph, host, plugin, plugin_instance, dtype) {
var p = []; var p = [];
var hide_free = uci.get("luci_statistics", "collectd_memory", "HideFree") == "1" ? true : false;
var memory = { var memory = {
title: "%H: Memory usage", title: "%H: Memory usage",
@ -21,7 +23,7 @@ return baseclass.extend({
data: { data: {
instances: { instances: {
memory: [ memory: [
"free", ...(hide_free ? [] : ["free"]),
"buffered", "buffered",
"cached", "cached",
"used" "used"
@ -58,7 +60,7 @@ return baseclass.extend({
data: { data: {
instances: { instances: {
percent: [ percent: [
"free", ...(hide_free ? [] : ["free"]),
"buffered", "buffered",
"cached", "cached",
"used" "used"

View file

@ -11,6 +11,11 @@ return baseclass.extend({
o = s.option(form.Flag, 'enable', _('Enable this plugin')); 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 = s.option(form.Flag, 'ValuesAbsolute', _('Absolute values'), _('When set to true, we request absolute values'));
o.default = '1'; o.default = '1';
o.depends('enable', '1'); o.depends('enable', '1');

View file

@ -158,6 +158,7 @@ config statistics 'collectd_load'
config statistics 'collectd_memory' config statistics 'collectd_memory'
option enable '1' option enable '1'
option HideFree '0'
option ValuesAbsolute '1' option ValuesAbsolute '1'
option ValuesPercentage '0' option ValuesPercentage '0'