mirror of https://github.com/aredn/aredn.git
parent
2100e45495
commit
12120694af
|
@ -116,19 +116,6 @@ local lon = cursor:get("aredn", "@location[0]", "lon")
|
||||||
if lat and lon then
|
if lat and lon then
|
||||||
lat_lon = string.format("<center><strong>Location: </strong> %s %s</center>", lat, lon)
|
lat_lon = string.format("<center><strong>Location: </strong> %s %s</center>", lat, lon)
|
||||||
end
|
end
|
||||||
-- low memory mitigation
|
|
||||||
local lowmemory = cursor:get("aredn", "@meshstatus[0]", "lowmem")
|
|
||||||
if not lowmemory then
|
|
||||||
lowmemory = 10000
|
|
||||||
end
|
|
||||||
lowmemory = 1024 * tonumber(lowmemory)
|
|
||||||
local lowroutes = cursor:get("aredn", "@meshstatus[0]", "lowroutes")
|
|
||||||
if not lowroutes then
|
|
||||||
lowroutes = 1000
|
|
||||||
else
|
|
||||||
lowroutes = tonumber(lowroutes)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local routes = {}
|
local routes = {}
|
||||||
local links = {}
|
local links = {}
|
||||||
|
@ -142,31 +129,24 @@ local hosts = {}
|
||||||
local services = {}
|
local services = {}
|
||||||
local history = {}
|
local history = {}
|
||||||
|
|
||||||
local olsr_total = 0
|
|
||||||
local olsr_nodes = 0
|
|
||||||
local olsr_routes = 0
|
|
||||||
for i, node in ipairs(aredn.olsr.getOLSRRoutes())
|
for i, node in ipairs(aredn.olsr.getOLSRRoutes())
|
||||||
do
|
do
|
||||||
if node.genmask ~= 0 then -- don't count default route
|
if node.genmask ~= 0 and node.etx <= 50 then
|
||||||
olsr_total = olsr_total + 1
|
routes[node.destination] = { etx = node.etx }
|
||||||
if node.genmask ~= 32 then
|
|
||||||
olsr_nodes = olsr_nodes + 1
|
|
||||||
end
|
|
||||||
if node.etx <= 50 then
|
|
||||||
routes[node.destination] = { etx = node.etx }
|
|
||||||
olsr_routes = olsr_routes + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- low memory route reduction
|
-- low memory route reduction
|
||||||
if olsr_routes > lowroutes and nixio.sysinfo().freeram < lowmemory then
|
local lowmemory = 1024 * tonumber(cursor:get("aredn", "@meshstatus[0]", "lowmem") or 10000)
|
||||||
|
local lowroutes = tonumber(cursor:get("aredn", "@meshstatus[0]", "lowroutes") or 1000)
|
||||||
|
if #routes > lowroutes and nixio.sysinfo().freeram < lowmemory then
|
||||||
local list = {}
|
local list = {}
|
||||||
for k,v in pairs(routes)
|
for k,v in pairs(routes)
|
||||||
do
|
do
|
||||||
list[#list + 1] = { key = k, etx = v.etx }
|
list[#list + 1] = { key = k, etx = v.etx }
|
||||||
end
|
end
|
||||||
table.sort(list, function (a, b) return a.etx < b.etx end)
|
table.sort(list, function (a, b) return a.etx < b.etx end)
|
||||||
for i = lowroutes,olsr_routes
|
for i = lowroutes, #list - 1
|
||||||
do
|
do
|
||||||
routes[list[i].key] = nil
|
routes[list[i].key] = nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue