From: Jo-Philipp Wich Date: Tue, 13 Sep 2011 07:27:34 +0000 (+0000) Subject: modules/admin-full: add wireless live stats X-Git-Tag: 0.11.0~1769 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=2bc02e44b41ffbfcc0ccad59d09409b6bee5bbef modules/admin-full: add wireless live stats --- diff --git a/modules/admin-full/htdocs/luci-static/resources/wireless.svg b/modules/admin-full/htdocs/luci-static/resources/wireless.svg new file mode 100644 index 000000000..99d9840f6 --- /dev/null +++ b/modules/admin-full/htdocs/luci-static/resources/wireless.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/modules/admin-full/luasrc/controller/admin/status.lua b/modules/admin-full/luasrc/controller/admin/status.lua index 61704ff55..3b2305515 100644 --- a/modules/admin-full/luasrc/controller/admin/status.lua +++ b/modules/admin-full/luasrc/controller/admin/status.lua @@ -16,6 +16,8 @@ $Id$ module("luci.controller.admin.status", package.seeall) function index() + local function _(x) return x end + entry({"admin", "status"}, alias("admin", "status", "overview"), _("Status"), 20).index = true entry({"admin", "status", "overview"}, template("admin_status/index"), _("Overview"), 1) entry({"admin", "status", "iptables"}, call("action_iptables"), _("Firewall"), 2).leaf = true @@ -29,7 +31,10 @@ function index() entry({"admin", "status", "bandwidth"}, template("admin_status/bandwidth"), _("Realtime Traffic"), 7).leaf = true entry({"admin", "status", "bandwidth_status"}, call("action_bandwidth")).leaf = true - entry({"admin", "status", "connections"}, template("admin_status/connections"), _("Realtime Connections"), 8).leaf = true + entry({"admin", "status", "wireless"}, template("admin_status/wireless"), _("Realtime Wireless"), 8).leaf = true + entry({"admin", "status", "wireless_status"}, call("action_wireless")).leaf = true + + entry({"admin", "status", "connections"}, template("admin_status/connections"), _("Realtime Connections"), 9).leaf = true entry({"admin", "status", "connections_status"}, call("action_connections")).leaf = true entry({"admin", "status", "processes"}, cbi("admin_status/processes"), _("Processes"), 20) @@ -86,6 +91,27 @@ function action_bandwidth() end end +function action_wireless() + local path = luci.dispatcher.context.requestpath + local iface = path[#path] + + luci.http.prepare_content("application/json") + + local bwc = io.popen("luci-bwc -r %q 2>/dev/null" % iface) + if bwc then + luci.http.write("[") + + while true do + local ln = bwc:read("*l") + if not ln then break end + luci.http.write(ln) + end + + luci.http.write("]") + bwc:close() + end +end + function action_load() luci.http.prepare_content("application/json") diff --git a/modules/admin-full/luasrc/view/admin_status/wireless.htm b/modules/admin-full/luasrc/view/admin_status/wireless.htm new file mode 100644 index 000000000..77b21f77b --- /dev/null +++ b/modules/admin-full/luasrc/view/admin_status/wireless.htm @@ -0,0 +1,388 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2011 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +-%> + +<%- + local ntm = require "luci.model.network".init() + + local dev + local devices = { } + for _, dev in luci.util.vspairs(luci.sys.net.devices()) do + if dev:match("^wlan%d") or dev:match("^ath%d") or dev:match("^wl%d") then + devices[#devices+1] = dev + end + end + + local curdev = luci.dispatcher.context.requestpath + curdev = curdev[#curdev] ~= "wireless" and curdev[#curdev] or devices[1] +-%> + +<%+header%> + + + + +

<%:Realtime Wireless%>

+ + + + +
-
+
+ + + + + + + + + + + + + + + + + + + + + + +
<%:Signal:%>0 dBm<%:Average:%>0 dBm<%:Peak:%>0 dBm
<%:Noise:%>0 dBm<%:Average:%>0 dBm<%:Peak:%>0 dBm
+ +
+ + +
-
+
+ + + + + + + + + + + + +
<%:Phy Rate:%>0 MBit/s<%:Average:%>0 MBit/s<%:Peak:%>0 MBit/s
+ +<%+footer%>