diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index e05b396a..c0217065 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -420,11 +420,11 @@ html.print([[ ]]) @@ -517,15 +511,13 @@ if not next(localhosts) and not next(links) then os.exit(0) end --- main for page formatting -html.print("") - --- start main table row 1 left cell -html.print("") - --- insert center margin cell -html.print("") - --- start main table row1 right cell -html.print("") - ---------------------------- --- start main table row 2 ---------------------------- -html.print("
") - --- show local hosts table +-- show local node table html.print("") -html.print("") +html.print("") +html.print("") +html.print("") +html.print("") +html.print("") if next(localhosts) then local rows = {} @@ -605,91 +597,16 @@ end -- discard localhosts = nil ---end row 1 left cell -html.print("
This NodeLAN HostnameService Name
") - --- show OLSR entries row -html.print("") -html.print("") -html.print("") -if nixio.sysinfo().freeram < lowmemory then - html.print("") -end - --- show previous neighbors -html.print("") - -local rows = {} -local uptime = nixio.sysinfo().uptime -for ip, node in pairs(history) -do - if not (links[ip] or links[ipalias[ip]]) then - local age = uptime - tonumber(node.age) - local host = node.host - if host == "" then - host = ip - else - host = host:gsub("^mid%d+%.", ""):gsub("^dtdlink%.", "") - end - local row = "" - rows[#rows + 1] = { key = age, row = row } - end -end -if #rows > 0 then - table.sort(rows, function(a,b) return a.key < b.key end) - for _, row in ipairs(rows) - do - html.print(row.row) - end - -- discard - rows = nil -else - html.print("") -end - --- end row 1 right table and cell -html.print("
OLSR Entries
Nodes: " .. olsr_nodes .. "Total: " .. olsr_total .. "
NOTE: Counts are correct but page may be truncated on this low memory node
Previous Neighbors
" .. host - if hosts[ip] and hosts[ip].hosts then - for _, v in ipairs(hosts[ip].hosts) - do - row = row .. "
" .. v - end - end - row = row .. "
" - if age < 3600 then - local val = math.floor(age / 60) - if val == 1 then - row = row .. "1 minute ago" - else - row = row .. val .. " minutes ago" - end - else - local val = string.format("%.1f", age / 3600) - if val == "1.0" then - row = row .. "1 hour ago" - else - row = row .. val .. " hours ago" - end - end - row = row .. "
none
") +-- end local node table +html.print("
") -- show current neighbors table html.print("
") -html.print("") +html.print("") html.print("") html.print("") -html.print("") +--html.print("") +html.print("") html.print("") local rows = {} @@ -741,10 +658,11 @@ do if nodeiface then row = row .. "   (" .. nodeiface .. ")" end - row = row .. string.format("", 100 * link.lq, 100 * link.nlq, link.mbps) if not neighservices[name] then neighservices[name] = true + row = row .. "" - row = row .. "") end --- end row 2 table and cell -html.print("
LQNLQTxMbpsService NameService Name
%.0f%%%.0f%%%s\n", 100 * link.lq, 100 * link.nlq, link.mbps) + row = row .. string.format("%.0f%%%.0f%%%s" if services[name] then for _, v in pairs(services[name]) do @@ -760,7 +678,7 @@ do local localpart = dmzhost:match("(.*)%.local%.mesh") if localpart then row = row .. "
" .. localpart .. "" + row = row .. "" if services[dmzhost] then for _, v in pairs(services[dmzhost]) do @@ -787,17 +705,63 @@ else html.print("
none
") +--add previous neighbors +local rows = {} +local uptime = nixio.sysinfo().uptime +for ip, node in pairs(history) +do + if not (links[ip] or links[ipalias[ip]]) then + local age = uptime - tonumber(node.age) + local host = node.host + if host == "" then + host = ip + else + host = host:gsub("^mid%d+%.", ""):gsub("^dtdlink%.", "") + end + local row = "" .. host + if hosts[ip] and hosts[ip].hosts then + for _, v in ipairs(hosts[ip].hosts) + do + row = row .. "
" .. v + end + end + row = row .. "" + if age < 3600 then + local val = math.floor(age / 60) + if val == 1 then + row = row .. "1 minute ago" + else + row = row .. val .. " minutes ago" + end + else + local val = string.format("%.1f", age / 3600) + if val == "1.0" then + row = row .. "1 hour ago" + else + row = row .. val .. " hours ago" + end + end + row = row .. "" + rows[#rows + 1] = { key = age, row = row } + end +end +if #rows > 0 then + html.print("Previous Neighbors") + table.sort(rows, function(a,b) return a.key < b.key end) + for _, row in ipairs(rows) + do + html.print(row.row) + end + -- discard + rows = nil +end ---------------------------- --- start main table row 3 ---------------------------- -html.print("") +-- end current neighbors table +html.print("") -- show remote node table html.print("
") -html.print("") +html.print("") html.print("") html.print("
") html.print("ETX") @@ -888,19 +852,13 @@ midcount = nil wangateway = nil services = nil --- end bottom left table cell -html.print("
") - -- discard links = nil ipalias = nil hosts = nil history = nil --- end row3 table and cell -html.print("") - ---end page format table +-- end remote nodes table html.print("") html.print("") @@ -931,3 +889,4 @@ html.print([[ html.footer(); html.print("") html.print("") +