From 139c5f66e58e641d2b21fabd5a2eca84fba87566 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Fri, 9 Feb 2024 20:45:52 -0800 Subject: [PATCH] Merge the LQM info onto the Mesh page (#1095) --- files/usr/lib/lua/aredn/nav/user/20lqm.lua | 3 - files/www/cgi-bin/mesh | 178 ++++++++++++++++++--- 2 files changed, 156 insertions(+), 25 deletions(-) delete mode 100644 files/usr/lib/lua/aredn/nav/user/20lqm.lua diff --git a/files/usr/lib/lua/aredn/nav/user/20lqm.lua b/files/usr/lib/lua/aredn/nav/user/20lqm.lua deleted file mode 100644 index cc9042a4..00000000 --- a/files/usr/lib/lua/aredn/nav/user/20lqm.lua +++ /dev/null @@ -1,3 +0,0 @@ -if uci.cursor():get("aredn", "@lqm[0]", "enable") == "1" then - return { href = "lqm", display = "Neighbor Status", hint = "See the link status to our neighbors", enable = not config_mode } -end diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index cca27cd1..84057522 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -44,6 +44,7 @@ require("uci") aredn.info = require("aredn.info") aredn.olsr = require("aredn.olsr") require("iwinfo") +require('luci.jsonc') local html = aredn.html @@ -410,10 +411,10 @@ html.print([[ width: 25%; } #nTable th:nth-child(2) { - width: 45%; + width: 50%; } #nTable th:nth-child(3) { - width: 30%; + width: 25%; } #cTable { margin-bottom: 12px; @@ -422,20 +423,31 @@ html.print([[ width: 25%; } #cTable th:nth-child(2), #rTable th:nth-child(2) { - width: 25%; - } - #cTable th:nth-child(3), #cTable th:nth-child(4) { - width: 6%; - } - #cTable th:nth-child(5) { - width: 8%; - } - #rTable th:nth-child(3) { width: 20%; } - #rTable th:nth-child(4) { + #cTable th:nth-child(3), #cTable th:nth-child(4), #cTable th:nth-child(5) { + width: 4%; + padding: 0 2px 0 0; + text-align: right; + } + #cTable th:nth-child(6), #cTable th:nth-child(7), #cTable th:nth-child(8) { + width: 6%; + padding: 0 2px 0 0; + text-align: right; + } + #cTable td:nth-child(3), #cTable td:nth-child(4), #cTable td:nth-child(5), #cTable td:nth-child(6), #cTable td:nth-child(7), #cTable td:nth-child(8) { + text-align: right; + padding: 0 2px 0 0; + } + #cTable th:nth-child(9) { + width: 25%; + } + #rTable th:nth-child(3) { width: 30%; } + #rTable th:nth-child(4) { + width: 25%; + } tr.s.f.nf { display: table-row; } @@ -524,7 +536,7 @@ end html.print("") html.print("") -html.print("") +html.print("") html.print("") html.print("") html.print("") @@ -620,12 +632,22 @@ html.print("
Node NameNode NameLAN HostnameService Name
") -- show current neighbors table html.print("") -html.print("") +html.print("") html.print("") -html.print("") +html.print("") +html.print("") html.print("") html.print("") +local trackers = {} +local l = io.open("/tmp/lqm.info") +if l then + local lqm = luci.jsonc.parse(l:read("*a")) + l:close() + trackers = lqm.trackers +end +local now = nixio.sysinfo().uptime + local rows = {} local neighservices = {} for ip, link in pairs(links) @@ -674,15 +696,68 @@ do nodeiface = "wan" end end - if nodeiface then - c1 = c1 .. "   (" .. nodeiface .. ")" - end + local c2 = "" local c3 = string.format("%.0f%%", math.min(100, math.ceil(100 * link.lq * link.weight))) local c4 = string.format("%.0f%%", math.min(100, math.ceil(100 * link.nlq * link.weight))) + local c4b = "" + local c4c = "" local c5 = string.format("%s", link.mbps) + local c5b = "" local c6 = "" + -- lqm info + local lqmstatus = nil + for _, track in pairs(trackers) + do + if track.ip == ipmain then + if track.hidden or track.blocked then + break + end + if track.pending > now then + lqmstatus = "pending" + elseif track.routable then + lqmstatus = "active" + else + lqmstatus = "idle" + end + if track.snr > 0 then + c4b = track.snr + if track.rev_snr then + c4b = c4b .. "/" .. track.rev_snr + end + end + if track.quality then + c4c = track.quality .. "%" + end + if track.distance then + if true then + local v = track.distance * 0.000621371 + if v > 1 then + c5b = math.ceil(v) .. " miles" + elseif v > 0.5 then + c5b = "1 mile" + end + else + c5b = math.ceil(track.distance * 0.001) .. " km" + end + end + break + end + end + + if nodeiface then + if lqmstatus then + c1 = c1 .. " (" .. nodeiface .. "," .. lqmstatus .. ")" + else + c1 = c1 .. " (" .. nodeiface .. ")" + end + else + if lqmstatus then + c1 = c1 .. " (" .. lqmstatus .. ")" + end + end + -- print node services if any if not neighservices[name] then neighservices[name] = true @@ -719,8 +794,67 @@ do end end -- Build this row - local row = "" - rows[#rows + 1] = { key = name, row = row } + local row = "" + rows[#rows + 1] = { key = name:lower(), row = row } +end +for _, track in pairs(trackers) +do + if track.blocked or track.hidden then + local name = track.ip + if track.hostname then + name = track.hostname + end + local c1 = "" .. name .. "" + local c4c = "" + local c4b = "" + local c5b = "" + if track.blocked then + if track.blocks.user then + c1 = c1 .. " (blocked user)" + elseif track.blocks.dtd then + c1 = c1 .. " (blocked dtd)" + elseif track.blocks.distance then + c1 = c1 .. " (blocked distance)" + elseif track.blocks.signal then + c1 = c1 .. " (blocked signal)" + elseif track.blocks.dup then + c1 = c1 .. " (blocked dup)" + elseif track.blocks.quality then + if track.tx_quality < track.ping_quality then + c1 = c1 .. " (blocked retries)" + else + c1 = c1 .. " (blocked latency)" + end + else + c1 = c1 .. " (blocked)" + end + if track.snr > 0 then + c4b = track.snr + if track.rev_snr then + c4b = c4b .. "/" .. track.rev_snr + end + end + if track.quality then + c4c = track.quality .. "%" + end + elseif track.hidden then + c1 = c1 .. " (hidden)" + end + if track.distance then + if true then + local v = track.distance * 0.000621371 + if v > 1 then + c5b = math.ceil(v) .. " miles" + elseif v > 0.5 then + c5b = "1 mile" + end + else + c5b = math.ceil(track.distance * 0.001) .. " km" + end + end + local row = "" + rows[#rows + 1] = { key = name:lower(), row = row } + end end if #rows > 0 then table.sort(rows, function(a,b) return a.key < b.key end) @@ -790,7 +924,7 @@ html.print("
Current NeighborsCurrent NeighborsLAN HostnameLQNLQTxMbpsLQNLQSNRQualityTxMbpsDistanceService Name
" .. c1 .. "" .. c2 .. "" .. c3 .. "" .. c4 .. "" .. c5 .. "" .. c6 .. "
" .. c1 .. "" .. c2 .. "" .. c3 .. "" .. c4 .. "" .. c4b .. "" .. c4c .. "" .. c5 .. "" .. c5b .. "" .. c6 .. "
" .. c1 .. "" .. c4b .. "" .. c4c .. "" .. c5b .. "
") -- show remote node table html.print("") -html.print("") +html.print("") html.print("") html.print("") html.print("") @@ -894,7 +1028,7 @@ do end -- Build this row local row = "" - rows[#rows + 1] = { key = string.format("%05d/%s", math.floor(100 * host.etx), host.name), row = row } + rows[#rows + 1] = { key = string.format("%05d/%s", math.floor(100 * host.etx), host.name:lower()), row = row } end end end
Remote NodesRemote NodesLAN HostnameETXService Name
" .. c1 .. "" .. c2 .. "" .. c3 .. "" .. c4 .. "