%
require "luci.sys"
require "luci.tools.webadmin"
-- System
local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
local uptime = luci.sys.uptime()
local load1, load5, load15 = luci.sys.loadavg()
local load = string.format("%.2f, %.2f, %.2f", load1, load5, load15)
local memory = string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
tonumber(memtotal) / 1024,
100 * memcached / memtotal,
tostring(translate("cached")),
100 * membuffers / memtotal,
tostring(translate("buffered")),
100 * memfree / memtotal,
tostring(translate("free"))
)
local_time = os.date("%c")
local uptime = luci.tools.webadmin.date_format(tonumber(uptime))
-- Wireless
local uci = require "luci.model.uci".cursor()
ifaces = {}
uci:foreach("wireless", "wifi-iface", function(s)
if s.network then
table.insert(ifaces, s.network)
if (uci:get("network", s.network, "ifname")) then
has_ifaces = true
end
end
end)
-- Routes
local defroutev4 = luci.sys.net.defaultroute()
local defroutev6 = luci.sys.net.defaultroute6 ()
%>
<%+header%>
<%:System%>
<%=system%>
<%=model%>
<%=load%>
<%=memory%>
<%=local_time%>
<%=uptime%>
<% if has_ifaces == true then %>
<%:Wireless Overview%>
<%:Signal%>
<%:Bitrate%>
<%:SSID%>
<%:BSSID%>
<%:Channel%>
<%:Mode%>
<%:TX%>-<%:Power%>
<% for k,v in pairs(ifaces) do
local iface = uci:get("network", v, "ifname")
if iface then
iwinf = luci.sys.wifi.getiwinfo(iface)
local signal = iwinf.signal
local noise = iwinf.noise
local q = iwinf.quality
local qmax = iwinf.quality_max
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 = ""
local ssid = iwinf.ssid
local bssid = iwinf.bssid
local chan = iwinf.channel
local mode = iwinf.mode
local txpwr = iwinf.txpower.." dbm"
local bitrate = (iwinf.bitrate / 1000).."Mb/s"
%>
<%=signal_string%>
<%=bitrate%>
<%=ssid%>
<%=bssid%>
<%=chan%>
<%=mode%>
<%=txpwr%>
<% end %>
<% end %>
<% end %>
<%:Default routes%>
<% if not defroutev4 and not defroutev6 then %>
<%:No defaultroutes known.%>
<%else%>