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 = "" .. tspace .. " KB" -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 = "" .. rspace .. " KB" else rspace = rspace .. " KB" end -col2[#col2 + 1] = "load average
free space" .. string.format("%.2f, %.2f, %.2f", sysinfo.loads[1], sysinfo.loads[2], sysinfo.loads[3]) .. "
flash = " .. fspace .. "
/tmp = " .. tspace .. "
memory = " .. rspace .. ""; -col2[#col2 + 1] = "Host EntriesTotal = " .. host_total .. "
Nodes = " .. host_nodes .. "" +col2[#col2 + 1] = "load average
available space" .. string.format("%.2f, %.2f, %.2f", sysinfo.loads[1], sysinfo.loads[2], sysinfo.loads[3]) .. "
flash = " .. fspace .. "
memory = " .. rspace .. ""; +col2[#col2 + 1] = "Host EntriesTotal = " .. host_total .. "
Nodes = " .. host_nodes .. "" -- now print the tables