diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index 8ad8eebf..fabae9e8 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -407,23 +407,51 @@ if nixio.fs.stat("/tmp/node.history") then end end +------------------ +-- generate page +------------------ http_header() html.header(node .. " mesh status", false) local automesh = nixio.fs.stat("/tmp/web/automesh"); if automesh then html.print("") end +html.print([[ + +]]) html.print("") -html.print("
") +html.print("") html.print("") html.print("
") - html.alert_banner() -html.msg_banner() - html.print("

" .. node .. " mesh status

") - html.print(lat_lon) if node_desc then html.print("
" .. node_desc .. "
") @@ -442,7 +470,6 @@ end html.print("  ") html.print("") - html.print("

") if not next(localhosts) and not next(links) then @@ -453,12 +480,15 @@ if not next(localhosts) and not next(links) then os.exit(0) end -html.print("") -html.print("") -html.print("") -html.print("") +-- insert center margin cell +html.print("") + +-- start main table row1 right cell +html.print("") -html.print("
") +-- main for page formatting +html.print("
") --- show local hosts +-- start main table row 1 left cell +html.print("") -html.print("") +-- show local hosts table +html.print("
") -html.print("
Local HostsServices

") +html.print("") if next(localhosts) then local rows = {} @@ -469,18 +499,19 @@ if next(localhosts) then if host.tactical ~= "" then tactical = " / " .. host.tactical end - local row = "" + -- add locally advertised dmz hosts for i, dmzhost in ipairs(host.hosts) do @@ -502,17 +533,17 @@ if next(localhosts) then end local localpart = dmzhost:match("(.*)%.local%.mesh") if not nopropd and not aliased then - row = row .. "" + row = row .. "" elseif aliased then - row = row .. "" + row = row .. "" else - row = row .. "" + row = row .. "" end if services[dmzhost] then - row = row .. "" @@ -533,73 +564,65 @@ end -- discard localhosts = nil --- show remote nodes +--end row 1 left cell +html.print("
This NodeLAN HostnameService Name
" .. localpart .. tactical .. "" + local row = "
" .. localpart .. tactical if wangateway[ip] then row = row .. "   (wan)" end - row = row .. " " + row = row .. "" if services[host.name] then for n, v in pairs(services[host.name]) do - row = row .. "" .. v .. "
" + row = row .. v .. "
" end end row = row .. "
 " .. localpart .. "
" .. localpart .. "
 " .. localpart .. "
" .. localpart .. "
 " .. localpart .."
" .. localpart .." " + row = row .. "" for n, v in pairs(services[dmzhost]) do - row = row .. "" .. v .. "
" + row = row .. v .. "
" end end row = row .. "
 
Remote Nodes  ETX  Services

") + +-- 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 = {} -for ip, host in pairs(hosts) +local uptime = nixio.sysinfo().uptime +for ip, node in pairs(history) do - if not neighbor[ip] and host.name then - local localpart = host.name:match("(.*)%.local%.mesh") - local tactical = "" - if host.tactical then - tactical = " / " .. host.tactical + 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 etx = string.format("%.2f", host.etx) - local row = "" - -- add locally advertised dmz hosts - for _, dmzhost in ipairs(host.hosts) - do - local localpart = dmzhost:match("(.*)%.local%.mesh") - row = row .. "" - row = row .. "" - end - rows[#rows + 1] = { key = host.etx, row = 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) @@ -612,17 +635,21 @@ else html.print("") end --- discard -neighbor = nil -dtd = nil -midcount = nil +-- 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
" .. localpart .. tactical .. "" - local nodeiface - local mycount = 0 - if midcount[ip] then - mycount = midcount[ip] - end - if dtd[ip] then - mycount = mycount - 1 - end - if hosts[ip].tactical then - mycount = mycount - 1 - end - if mycount > 0 then - nodeiface = "tun*" .. mycount - end - if wangateway[ip] then - if nodeiface then - nodeiface = nodeiface .. ",wan" - else - nodeiface = "wan" + local row = "
" .. host + if hosts[ip] and hosts[ip].hosts then + for _, v in ipairs(hosts[ip].hosts) + do + row = row .. "
" .. v end end - if nodeiface then - row = row .. "   (" .. nodeiface .. ")" - end - row = row .. "
" .. etx .. "" - if services[host.name] then - for _, v in pairs(services[host.name]) - do - row = row .. "" .. v .. "
" + 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 .. "
 " .. localpart .. "" - if services[dmzhost] then - for _, v in pairs(services[dmzhost]) - do - row = row .. "" .. v .. "
" - end - end - row = row .. "
none
 ") +--------------------------- +-- start main table row 2 +--------------------------- +html.print("") -html.print("") +-- show current neighbors table +html.print("
") --- show current neighbors - -html.print("
Current Neighbors  LQNLQTxMbps  Services

") +html.print("") +html.print("") +html.print("") +html.print("") +html.print("") local rows = {} local neighservices = {} @@ -652,7 +679,7 @@ do name = name .. " " -- avoid collision 2 links to same host {rf, dtd} end local no_space_host = name:match("(.*%S)%s*$") - local row = "" + -- add advertised dmz hosts if host then for _, dmzhost in ipairs(host.hosts) do local localpart = dmzhost:match("(.*)%.local%.mesh") - row = row .. "" - row = row .. "" + row = row .. "") end --- discard -wangateway = nil -services = nil +-- end row 2 table and cell +html.print("
LQNLQTxMbpsService Name
" .. localpart .. tactical .. "" + local row = "
" .. localpart .. tactical .. "" local nodeiface if ipmain ~= ip then if links[ip].dtd then @@ -673,24 +700,25 @@ do if nodeiface then row = row .. "   (" .. nodeiface .. ")" end - row = row .. string.format("%.0f%%%.0f%%%s\n", 100 * link.lq, 100 * link.nlq, link.mbps) + row = row .. string.format("%.0f%%%.0f%%%s\n", 100 * link.lq, 100 * link.nlq, link.mbps) if not neighservices[name] then neighservices[name] = true if services[name] then for _, v in pairs(services[name]) do - row = row .. "" .. v .. "
" + row = row .. v .. "
" end end row = row .. "
 " .. localpart .. "" + row = row .. "
" .. localpart .. "" if services[dmzhost] then for _, v in pairs(services[dmzhost]) do @@ -716,55 +744,85 @@ else html.print("
none
") --- show previous neighbors +--------------------------- +-- start main table row 3 +--------------------------- +html.print("") + +-- show remote node table +html.print("
") +html.print("") +html.print("") +html.print("") -html.print("") -html.print("") -html.print("") local rows = {} -local uptime = nixio.sysinfo().uptime -for ip, node in pairs(history) +for ip, host in pairs(hosts) 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%.", "") + if not neighbor[ip] and host.name then + local localpart = host.name:match("(.*)%.local%.mesh") + local tactical = "" + if host.tactical then + tactical = " / " .. host.tactical end - local row = "" + + -- add locally advertised dmz hosts + for _, dmzhost in ipairs(host.hosts) + do + local localpart = dmzhost:match("(.*)%.local%.mesh") + row = row .. "" + row = row .. "" end - rows[#rows + 1] = { key = age, row = row } + + rows[#rows + 1] = { key = host.etx, 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) @@ -776,6 +834,15 @@ if #rows > 0 then else html.print("") end +-- discard +neighbor = nil +dtd = nil +midcount = nil +wangateway = nil +services = nil + +-- end bottom left table cell +html.print("
") +html.print("ETX") +html.print("
 
Previous NeighborsWhen

" .. host .. "" - if hosts[ip] and hosts[ip].hosts then - for _, v in ipairs(hosts[ip].hosts) + local etx = string.format("%.2f", host.etx) + local row = "
" .. localpart .. tactical .. "" + local nodeiface + local mycount = 0 + if midcount[ip] then + mycount = midcount[ip] + end + if dtd[ip] then + mycount = mycount - 1 + end + if hosts[ip].tactical then + mycount = mycount - 1 + end + if mycount > 0 then + nodeiface = "tun*" .. mycount + end + if wangateway[ip] then + if nodeiface then + nodeiface = nodeiface .. ",wan" + else + nodeiface = "wan" + end + end + if nodeiface then + row = row .. "   (" .. nodeiface .. ")" + end + row = row .. "" .. etx .. "" + if services[host.name] then + for _, v in pairs(services[host.name]) do - row = row .. "
" .. v .. "" + 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" + row = row .. "
" .. localpart .. "" + if services[dmzhost] then + for _, v in pairs(services[dmzhost]) + do + row = row .. v .. "
" + end 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 - row = row .. "
none
") -- discard links = nil @@ -783,21 +850,37 @@ ipalias = nil hosts = nil history = nil --- footer +-- end row3 table and cell +html.print("") -html.print(" ") -html.print("OLSR Entries") -html.print("
") -html.print("Total " .. olsr_total .. "") -html.print("Nodes " .. olsr_nodes .. "") -if nixio.sysinfo().freeram < lowmemory then - html.print(" NOTE: Counts are correct but page may be truncated to save node memory ") -end -html.print("") +--end page format table +html.print("") html.print("
") html.print("
") +html.print([[ + +]]) html.footer(); html.print("") html.print("")