X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=modules%2Ffreifunk%2Fluasrc%2Fview%2Ffreifunk%2Fpublic_status.htm;h=10bd849d7dab110314fc29a5dcfe8893c316ef20;hb=9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4;hp=1698e9c23b1a9cb9fa0fd117a52fc3d7525f4d2a;hpb=8cd629e14820d30c3f4ecd981b35c58b99cf592d;p=project%2Fluci.git diff --git a/modules/freifunk/luasrc/view/freifunk/public_status.htm b/modules/freifunk/luasrc/view/freifunk/public_status.htm index 1698e9c23..10bd849d7 100644 --- a/modules/freifunk/luasrc/view/freifunk/public_status.htm +++ b/modules/freifunk/luasrc/view/freifunk/public_status.htm @@ -1,12 +1,11 @@ <% - local sys = require "luci.sys" local twa = require "luci.tools.webadmin" -- System -local system, model, memtotal, memcached, membuffers, memfree, bogomips = sys.sysinfo() +local model, system, memtotal, memcached, membuffers, memfree, bogomips = sys.sysinfo() local uptime = twa.date_format(tonumber(sys.uptime())) -local_time = os.date("%c") +local time = os.date("%a, %d %b %Y, %H:%M:%S") local load1, load5, load15 = sys.loadavg() local load = string.format("%.2f, %.2f, %.2f", load1, load5, load15) @@ -25,11 +24,9 @@ local mem = string.format( -- update interval local bogomips = bogomips or 100 -local interval +local interval = 10 if bogomips > 350 then - interval = "5000" -else - interval = "10000" + interval = 5 end -- wireless @@ -51,127 +48,183 @@ local has_iwinfo = pcall(require, "iwinfo") local defroutev4 = sys.net.defaultroute() local defroutev6 = sys.net.defaultroute6() +if defroutev4 then + defroutev4.dest = defroutev4.dest:string() + defroutev4.gateway = defroutev4.gateway:string() +else + -- probably policy routing activated, try olsr-default table + local dr4 = sys.exec("ip r s t olsr-default") + if dr4 then + defroutev4 = { } + defroutev4.dest, defroutev4.gateway, defroutev4.device, defroutev4.metric = dr4:match("^(%w+) via (%d+.%d+.%d+.%d+) dev ([%w-]+) +metric (%d+)") + end +end + +if defroutev6 then + defroutev6.dest = defroutev6.dest:string() + defroutev6.nexthop = defroutev6.nexthop:string() +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 + + if defroutev6 then + def6 = { + gateway = defroutev6.nexthop, + dest = defroutev6.dest, + dev = defroutev6.device, + metr = defroutev6.metric + } + end + + if defroutev4 then + def4 = { + gateway = defroutev4.gateway, + dest = defroutev4.dest, + dev = defroutev4.device, + metr = defroutev4.metric + } + 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%> -
@@ -181,7 +234,7 @@ local defroutev6 = sys.net.defaultroute6()
<%=model%>
<%=load%>
<%=mem%>
-
<%=local_time%>
+
<%=time%>
<%=uptime%>
@@ -190,7 +243,7 @@ local defroutev6 = sys.net.defaultroute6()

<%:Wireless Overview%>

- + <% if not has_iwinfo then %>
<%:Package libiwinfo required!%>
@@ -211,14 +264,14 @@ local defroutev6 = sys.net.defaultroute6() <%:TX%>-<%:Power%> <%:Interface%> - <% + <% 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.ifname then + 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" @@ -293,9 +346,9 @@ local defroutev6 = sys.net.defaultroute6() <% if defroutev4 then %> - <%=defroutev4.dest:string()%> + <%=defroutev4.dest%> <%=defroutev4.device%> - <%=defroutev4.gateway:string()%> + <%=defroutev4.gateway%> <%=defroutev4.metric%> @@ -303,9 +356,9 @@ local defroutev6 = sys.net.defaultroute6() if defroutev6 then %> - <%=defroutev6.dest:string()%> + <%=defroutev6.dest%> <%=defroutev6.device%> - <%=defroutev6.nexthop:string()%> + <%=defroutev6.nexthop%> <%=defroutev6.metric%>