")
+-- main for page formatting
+html.print("")
--- show local hosts
+-- start main table row 1 left cell
+html.print("")
-html.print(" | Local Hosts | Services | ")
-html.print("
| ")
+-- show local hosts table
+html.print("")
+html.print("This Node | LAN Hostname | Service Name | ")
if next(localhosts) then
local rows = {}
@@ -469,18 +499,19 @@ if next(localhosts) then
if host.tactical ~= "" then
tactical = " / " .. host.tactical
end
- local row = "" .. 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 .. " | "
+
-- 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 .. " " .. localpart .. " | "
+ row = row .. " | " .. localpart .. " | "
elseif aliased then
- row = row .. " " .. localpart .. " | "
+ row = row .. " | " .. localpart .. " | "
else
- row = row .. " " .. localpart .." | "
+ row = row .. " | " .. localpart .." | "
end
if services[dmzhost] then
- row = row .. " | "
+ row = row .. " | "
for n, v in pairs(services[dmzhost])
do
- row = row .. "" .. v .. " "
+ row = row .. v .. " "
end
end
row = row .. " | "
@@ -533,73 +564,65 @@ end
-- discard
localhosts = nil
--- show remote nodes
+--end row 1 left cell
+html.print(" ")
-html.print(" | ")
-html.print("Remote Nodes | | ETX | | Services | ")
-html.print("
| ")
+-- insert center margin cell
+html.print(" | ")
+
+-- start main table row1 right cell
+html.print("")
+
+-- show OLSR entries row
+html.print("")
+html.print("OLSR Entries | ")
+html.print("Nodes: " .. olsr_nodes .. " | Total: " .. olsr_total .. " | ")
+if nixio.sysinfo().freeram < lowmemory then
+ html.print("NOTE: Counts are correct but page may be truncated on this low memory node | ")
+end
+
+-- show previous neighbors
+html.print("Previous Neighbors | ")
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 = "" .. 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 .. " | "
- -- add locally advertised dmz hosts
- for _, dmzhost in ipairs(host.hosts)
- do
- local localpart = dmzhost:match("(.*)%.local%.mesh")
- row = row .. " " .. localpart .. " | "
- row = row .. " | "
- if services[dmzhost] then
- for _, v in pairs(services[dmzhost])
- do
- row = row .. "" .. v .. " "
- end
- end
- 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("none | ")
end
--- discard
-neighbor = nil
-dtd = nil
-midcount = nil
+-- end row 1 right table and cell
+html.print(" | | ")
-html.print(" | ")
+---------------------------
+-- start main table row 2
+---------------------------
+html.print("")
--- show current neighbors
-
-html.print(" | Current Neighbors | | LQ | NLQ | TxMbps | | Services | ")
-html.print("
| ")
+-- show current neighbors table
+html.print("
")
+html.print(" | ")
+html.print(" | ")
+html.print("LQ | NLQ | TxMbps | ")
+html.print("Service Name | ")
+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 = "" .. 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 .. " | "
+
-- add advertised dmz hosts
if host then
for _, dmzhost in ipairs(host.hosts)
do
local localpart = dmzhost:match("(.*)%.local%.mesh")
- row = row .. " " .. localpart .. " | "
- row = row .. " | "
+ row = row .. " | | " .. localpart .. " | "
+ row = row .. " | "
if services[dmzhost] then
for _, v in pairs(services[dmzhost])
do
@@ -716,55 +744,85 @@ else
html.print(" | none | ")
end
--- discard
-wangateway = nil
-services = nil
+-- end row 2 table and cell
+html.print(" | ")
--- show previous neighbors
+---------------------------
+-- start main table row 3
+---------------------------
+html.print("")
+
+-- show remote node table
+html.print("
")
+html.print(" | ")
+html.print("")
+html.print(" | ETX | ")
+html.print("")
+html.print(" | ")
-html.print(" | ")
-html.print("Previous Neighbors | When | ")
-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 = "" .. 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 .. " | "
+
+ -- add locally advertised dmz hosts
+ for _, dmzhost in ipairs(host.hosts)
+ do
+ local localpart = dmzhost:match("(.*)%.local%.mesh")
+ 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 .. " | "
+ 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("none | ")
end
+-- discard
+neighbor = nil
+dtd = nil
+midcount = nil
+wangateway = nil
+services = nil
+
+-- end bottom left table cell
+html.print("
| ")
-- 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(" |