From b436eb0545c710a3f0490a8721f78f4dc97a4144 Mon Sep 17 00:00:00 2001 From: Zachary Cook Date: Sat, 2 Nov 2019 17:01:58 -0400 Subject: [PATCH] luci-mod-status: use available and cached memory for progress bars Fixes: #1148 Uses available and cached memory from /proc/meminfo via procd, and carefully handles the cases where they are nil or zero, so as to not require specific linux or procd versions to function MemAvailable is a better estimate than free + buffered/cached, see: git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0 Also adds a new progressbar that shows cached memory if not nil Signed-off-by: Zachary Cook --- .../luci-static/resources/view/status/include/20_memory.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js index 9baf0420d..2e8477434 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js @@ -31,11 +31,14 @@ return L.Class.extend({ swap = L.isObject(systeminfo.swap) ? systeminfo.swap : {}; var fields = [ - _('Total Available'), (mem.total && mem.free && mem.buffered) ? mem.free + mem.buffered : null, + _('Total Available'), (mem.available) ? mem.available : (mem.total && mem.free && mem.buffered) ? mem.free + mem.buffered : null, _('Free'), (mem.total && mem.free) ? mem.free : null, _('Buffered'), (mem.total && mem.buffered) ? mem.buffered : null ]; + if (mem.cached) + fields.push(_('Cached'), mem.cached); + if (swap.total > 0) fields.push(_('Swap free'), swap.free); -- 2.25.1