From 9ff499cdccedbb3fdd70a52d48aee7d183963f9c Mon Sep 17 00:00:00 2001 From: Steve <69524416+ab7pa@users.noreply.github.com> Date: Thu, 10 Nov 2022 21:43:00 -0700 Subject: [PATCH] add kernel MemAvailable to Status page (#536) add larger of kernel MemAvailable or MemFree to Status page. This will show a value to be at least the size of unused RAM and can be larger if RAM can instantly be freed up to start a new process. --- files/www/cgi-bin/status | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status index 12e81a14..a7bea373 100755 --- a/files/www/cgi-bin/status +++ b/files/www/cgi-bin/status @@ -100,6 +100,22 @@ function get_default_gw() return "none" end +function get_memavail() + local f = io.open("/proc/meminfo", "r") + if f then + for line in f:lines() + do + local memavail = line:match("^MemAvailable:%s+(%d+)%s+kB") + if memavail then + f:close() + return tonumber(memavail) + end + end + f:close() + end + return 0 +end + function get_wifi_signal(wifiif) local signal = -1000 local noise = -1000 @@ -385,22 +401,21 @@ if fspace < 100 then else fspace = fspace .. " KB" end -vfs = nixio.fs.statvfs("/tmp") -local tspace = vfs.bfree * vfs.bsize / 1024 -if tspace < 3000 then - tspace = "" -else - tspace = tspace .. " KB" + +local rspace = sysinfo.freeram / 1024 +local mavail = get_memavail() +if rspace < mavail then + rspace = mavail end -local rspace = (sysinfo.freeram + sysinfo.bufferram) / 1024 + if rspace < 500 then rspace = "" else rspace = rspace .. " KB" end -col2[#col2 + 1] = "