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.
This commit is contained in:
Steve 2022-11-10 21:43:00 -07:00 committed by GitHub
parent cd661106a8
commit 9ff499cdcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 9 deletions

View File

@ -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 = "<blink><b>" .. tspace .. " KB</b></blink>"
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 = "<blink><b>" .. rspace .. " KB</b></blink>"
else
rspace = rspace .. " KB"
end
col2[#col2 + 1] = "<th align=right valign=top><nobr>load average</nobr><br><nobr>free space</nobr></th><td>" .. string.format("%.2f, %.2f, %.2f", sysinfo.loads[1], sysinfo.loads[2], sysinfo.loads[3]) .. "<br><nobr>flash = " .. fspace .. "</nobr><br><nobr>/tmp = " .. tspace .. "</nobr><br><nobr>memory = " .. rspace .. "</nobr></td>";
col2[#col2 + 1] = "<th align=right valign=top>Host Entries</th><td><nobr>Total = " .. host_total .. "<nobr><br><nobr>Nodes = " .. host_nodes .. "<nobr></td>"
col2[#col2 + 1] = "<th align=right valign=top><nobr>load average</nobr><br><nobr>available space</nobr></th><td>" .. string.format("%.2f, %.2f, %.2f", sysinfo.loads[1], sysinfo.loads[2], sysinfo.loads[3]) .. "<br><nobr>flash = " .. fspace .. "</nobr><br><nobr>memory = " .. rspace .. "</nobr></td>";
col2[#col2 + 1] = "<th align=right valign=top>Host Entries</th><td><nobr>Total = " .. host_total .. "</nobr><br><nobr>Nodes = " .. host_nodes .. "<nobr></td>"
-- now print the tables