mirror of https://github.com/aredn/aredn.git
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:
parent
cd661106a8
commit
9ff499cdcc
|
@ -100,6 +100,22 @@ function get_default_gw()
|
||||||
return "none"
|
return "none"
|
||||||
end
|
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)
|
function get_wifi_signal(wifiif)
|
||||||
local signal = -1000
|
local signal = -1000
|
||||||
local noise = -1000
|
local noise = -1000
|
||||||
|
@ -385,22 +401,21 @@ if fspace < 100 then
|
||||||
else
|
else
|
||||||
fspace = fspace .. " KB"
|
fspace = fspace .. " KB"
|
||||||
end
|
end
|
||||||
vfs = nixio.fs.statvfs("/tmp")
|
|
||||||
local tspace = vfs.bfree * vfs.bsize / 1024
|
local rspace = sysinfo.freeram / 1024
|
||||||
if tspace < 3000 then
|
local mavail = get_memavail()
|
||||||
tspace = "<blink><b>" .. tspace .. " KB</b></blink>"
|
if rspace < mavail then
|
||||||
else
|
rspace = mavail
|
||||||
tspace = tspace .. " KB"
|
|
||||||
end
|
end
|
||||||
local rspace = (sysinfo.freeram + sysinfo.bufferram) / 1024
|
|
||||||
if rspace < 500 then
|
if rspace < 500 then
|
||||||
rspace = "<blink><b>" .. rspace .. " KB</b></blink>"
|
rspace = "<blink><b>" .. rspace .. " KB</b></blink>"
|
||||||
else
|
else
|
||||||
rspace = rspace .. " KB"
|
rspace = rspace .. " KB"
|
||||||
end
|
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><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>"
|
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
|
-- now print the tables
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue