X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=modules%2Ffreifunk%2Fluasrc%2Fview%2Ffreifunk%2Fpublic_status.htm;fp=modules%2Ffreifunk%2Fluasrc%2Fview%2Ffreifunk%2Fpublic_status.htm;h=953cda6845c2fceddf544f1d213732381f67a0c8;hp=46bff695e2b329ea7f2944e93931d56ebdb8453a;hb=e2b8e5efa75adeb7a4141ae1b4697a14b642bf13;hpb=c6712bdc3c653d694d61bab01628f1621bcb73a3 diff --git a/modules/freifunk/luasrc/view/freifunk/public_status.htm b/modules/freifunk/luasrc/view/freifunk/public_status.htm index 46bff695e..953cda684 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 model, system, memtotal, memcached, membuffers, memfree, bogomips = sys.sysinfo() local uptime = twa.date_format(tonumber(sys.uptime())) -local_time = os.date("%a, %d %b %Y, %H:%M:%S") +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) @@ -53,23 +52,75 @@ 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+)") + 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 ipairs(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%> -