<% local utl = require "luci.util" local sys = require "luci.sys" local twa = require "luci.tools.webadmin" local ip = require "luci.ip" -- System local sysinfo = utl.ubus("system", "info") or { } local boardinfo = utl.ubus("system", "board") or { } local loads = sysinfo.load or { 0, 0, 0 } local meminfo = sysinfo.memory or { total = 0, free = 0, buffered = 0, shared = 0 } local uptime = twa.date_format(sysinfo.uptime or 0) local time = os.date("%a, %d %b %Y, %H:%M:%S") local load = string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0) local mem = string.format( "%.2f MB (%.2f %s, %.2f %s, %.2f %s)", meminfo.total / 1024 / 1024, (meminfo.total - meminfo.free) / 1024 / 1024, tostring(i18n.translate("used")), meminfo.free / 1024 / 1024, tostring(i18n.translate("free")), meminfo.buffered / 1024 / 1024, tostring(i18n.translate("buffered")) ) local interval = 5 -- wireless local ntm = require "luci.model.network".init() local devices = ntm:get_wifidevs() local netlist = { } local netdevs = { } local dev for _, dev in ipairs(devices) do local net for _, net in ipairs(dev:get_wifinets()) do netlist[#netlist+1] = net:ifname() netdevs[net:ifname()] = dev:name() end end local has_iwinfo = pcall(require, "iwinfo") -- Find default routes local _, r, def4, def6 for _, r in ipairs(ip.routes({ type = 1, dest_exact = "0.0.0.0/0" })) do def4 = { gateway = r.gw:string(), dest = r.dest:string(), dev = r.dev, metr = r.metric or 0 } break end for _, r in ipairs(ip.routes({ type = 1, dest_exact = "::/0" })) do def6 = { gateway = r.gw:string(), dest = r.dest:string(), dev = r.dev, metr = r.metric or 0 } break end if luci.http.formvalue("status") == "1" then local rv = { } for dev in pairs(netdevs) do local j = { id = dev } local iw = luci.sys.wifi.getiwinfo(dev) if iw then local f for _, f in ipairs({ "channel", "txpower", "bitrate", "signal", "noise", "quality", "quality_max", "mode", "ssid", "bssid", "encryption", "ifname" }) do j[f] = iw[f] end end rv[#rv+1] = j end rv[#rv+1] = { time = time, uptime = uptime, load = load, mem = mem, defroutev4 = def4, defroutev6 = def6 } luci.http.prepare_content("application/json") luci.http.write_json(rv) return end -%> <%+header%>

<%:System%>

<%=boardinfo.system or "?"%>
<%=boardinfo.model or "?"%>
<%=load%>
<%=mem%>
<%=time%>
<%=uptime%>
<% if devices[1] then %>

<%:Wireless Overview%>

<% if not has_iwinfo then %>
<%:Package libiwinfo required!%>
<%_The libiwinfo package is not installed. You must install this component for working wireless configuration!%>
<% end %>
<% for _, dev in ipairs(devices) do local net for _, net in ipairs(dev:get_wifinets()) do netlist[#netlist+1] = net:ifname() netdevs[net:ifname()] = dev:name() if net.iwdata.device then local signal = net.iwinfo.signal or "N/A" local noise = net.iwinfo.noise or "N/A" local q = net.iwinfo.quality or "0" local qmax = net.iwinfo.quality_max or "100" local qperc = q / qmax * 100 if qperc == 0 then icon = "signal-none.png" elseif qperc < 26 then icon = "signal-0-25.png" elseif qperc < 51 then icon = "signal-25-50.png" elseif qperc < 76 then icon = "signal-50-75.png" elseif qperc < 100 then icon = "signal-75-100.png" else icon = "signal-0.png" end signal_string = "Signal Quality" local ssid = net.iwinfo.ssid or "N/A" local bssid = net.iwinfo.bssid or "N/A" local chan = net.iwinfo.channel or "N/A" local mode = net.iwinfo.mode or "N/A" local txpwr = net.iwinfo.txpower or "N/A" if txpwr ~= "N/A" then txpwr = txpwr.." dbm" end local bitrate = net.iwinfo.bitrate or "N/A" if bitrate ~= "N/A" then bitrate = ( bitrate / 1000 ).."Mb/s" end local interface = net.iwinfo.ifname or "N/A" %> <% end end end %>
<%:Signal%> <%:Bitrate%> <%:SSID%> <%:BSSID%> <%:Channel%> <%:Mode%> <%:TX%>-<%:Power%> <%:Interface%>
<%=signal_string%> <%=bitrate%> <%=ssid%> <%=bssid%> <%=chan%> <%=mode%> <%=txpwr%> <%=interface%>
<% end %>

<%:Default routes%>

<% if not def4 and not def6 then %> <%:No default routes known.%> <%else%> <% if def4 then %> <% end if def6 then %> <% end %>
<%:Network%> <%:Interface%> <%:Gateway%> <%:Metric%>
<%=def4.dest%> <%=def4.dev%> <%=def4.gateway%> <%=def4.metr%>
<%=def6.dest%> <%=def6.dev%> <%=def6.gateway%> <%=def6.metr%>
<% end %>
<%+footer%>