modules/admin-full: rework index page
This commit is contained in:
parent
ce68705702
commit
0d478ab962
1 changed files with 304 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
<%#
|
||||
LuCI - Lua Configuration Interface
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
|
||||
Copyright 2008-2011 Jo-Philipp Wich <xm@subsignal.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -12,8 +12,308 @@ You may obtain a copy of the License at
|
|||
$Id$
|
||||
|
||||
-%>
|
||||
|
||||
<%
|
||||
if luci.http.formvalue("status") == "1" then
|
||||
local ntm = require "luci.model.network".init()
|
||||
local dr4 = luci.sys.net.defaultroute()
|
||||
local dr6 = luci.sys.net.defaultroute6()
|
||||
local wan, wan6
|
||||
|
||||
if dr4 and dr4.device then
|
||||
wan = ntm:get_interface(dr4.device)
|
||||
wan = wan and wan:get_network()
|
||||
end
|
||||
|
||||
if dr6 and dr6.device then
|
||||
wan6 = ntm:get_interface(dr6.device)
|
||||
wan6 = wan6 and wan6:get_network()
|
||||
end
|
||||
|
||||
local _, _, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
|
||||
|
||||
local conn_count = tonumber((
|
||||
luci.sys.exec("wc -l /proc/net/nf_conntrack") or
|
||||
luci.sys.exec("wc -l /proc/net/ip_conntrack") or
|
||||
""):match("%d+")) or 0
|
||||
|
||||
local conn_max = tonumber((
|
||||
luci.sys.exec("sysctl net.nf_conntrack_max") or
|
||||
luci.sys.exec("sysctl net.ipv4.netfilter.ip_conntrack_max") or
|
||||
""):match("%d+")) or 4096
|
||||
|
||||
local rv = {
|
||||
uptime = luci.sys.uptime(),
|
||||
localtime = os.date(),
|
||||
loadavg = { luci.sys.loadavg() },
|
||||
memtotal = memtotal,
|
||||
memcached = memcached,
|
||||
membuffers = membuffers,
|
||||
memfree = memfree,
|
||||
connmax = conn_max,
|
||||
conncount = conn_count
|
||||
}
|
||||
|
||||
if wan then
|
||||
rv.wan = {
|
||||
ipaddr = wan:ipaddr(),
|
||||
gwaddr = wan:gwaddr(),
|
||||
netmask = wan:netmask(),
|
||||
dns = wan:dnsaddrs(),
|
||||
expires = wan:expires(),
|
||||
uptime = wan:uptime(),
|
||||
proto = wan:proto(),
|
||||
ifname = wan:ifname(),
|
||||
link = wan:adminlink()
|
||||
}
|
||||
end
|
||||
|
||||
if wan6 then
|
||||
rv.wan6 = {
|
||||
ip6addr = wan6:ip6addr(),
|
||||
gw6addr = wan6:gw6addr(),
|
||||
dns = wan6:dns6addrs(),
|
||||
uptime = wan6:uptime(),
|
||||
ifname = wan6:ifname(),
|
||||
link = wan6:adminlink()
|
||||
}
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local system, model, _, _, _, _, bogomips = luci.sys.sysinfo()
|
||||
-%>
|
||||
|
||||
<%+header%>
|
||||
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function progressbar(v, m)
|
||||
{
|
||||
var vn = parseInt(v) || 0;
|
||||
var mn = parseInt(m) || 100;
|
||||
var pc = Math.floor((100 / mn) * vn);
|
||||
|
||||
return String.format(
|
||||
'<div style="width:200px; position:relative; border:1px solid #999999">' +
|
||||
'<div style="background-color:#CCCCCC; width:%d%%; height:15px">' +
|
||||
'<div style="position:absolute; left:0; top:0; text-align:center; width:100%%; color:#000000">' +
|
||||
'<small>%d / %d (%d%%)</small>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>', pc, v, m, pc
|
||||
);
|
||||
}
|
||||
|
||||
var iwxhr = new XHR();
|
||||
var wifidevs = <%=luci.http.write_json(netdevs)%>;
|
||||
var arptable = <%=luci.http.write_json(arpcache)%>;
|
||||
|
||||
var update_status = function() {
|
||||
iwxhr.get('<%=REQUEST_URI%>', { status: 1 },
|
||||
function(x, info)
|
||||
{
|
||||
var si = document.getElementById('wan4_i');
|
||||
var ss = document.getElementById('wan4_s');
|
||||
var ifc = info.wan;
|
||||
|
||||
if (ifc && ifc.ifname && ifc.proto != 'none')
|
||||
{
|
||||
var s = String.format(
|
||||
'<strong><%:Type%>: </strong>%s<br />' +
|
||||
'<strong><%:Address%>: </strong>%s<br />' +
|
||||
'<strong><%:Netmask%>: </strong>%s<br />' +
|
||||
'<strong><%:Gateway%>: </strong>%s<br />',
|
||||
ifc.proto,
|
||||
(ifc.ipaddr) ? ifc.ipaddr : '0.0.0.0',
|
||||
(ifc.netmask != ifc.ipaddr) ? ifc.netmask : '255.255.255.255',
|
||||
(ifc.gwaddr) ? ifc.gwaddr : '0.0.0.0'
|
||||
);
|
||||
|
||||
for (var i = 0; i < ifc.dns.length; i++)
|
||||
{
|
||||
s += String.format(
|
||||
'<strong><%:DNS%> %d: </strong>%s<br />',
|
||||
i + 1, ifc.dns[i]
|
||||
);
|
||||
}
|
||||
|
||||
if (ifc.expires > -1)
|
||||
{
|
||||
s += String.format(
|
||||
'<strong><%:Expires%>: </strong>%t<br />',
|
||||
ifc.expires
|
||||
);
|
||||
}
|
||||
|
||||
if (ifc.uptime > 0)
|
||||
{
|
||||
s += String.format(
|
||||
'<strong><%:Connected%>: </strong>%t<br />',
|
||||
ifc.uptime
|
||||
);
|
||||
}
|
||||
|
||||
ss.innerHTML = String.format('<small>%s</small>', s);
|
||||
si.innerHTML = String.format(
|
||||
'<a href="%s"><img src="<%=resource%>/icons/ethernet.png" /></a>' +
|
||||
'<br /><small>%s</small>', ifc.link, ifc.ifname
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
si.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>';
|
||||
ss.innerHTML = '<em>Not connected</em>';
|
||||
}
|
||||
|
||||
var si6 = document.getElementById('wan6_i');
|
||||
var ss6 = document.getElementById('wan6_s');
|
||||
var ifc6 = info.wan6;
|
||||
|
||||
if (ifc6 && ifc6.ifname && ifc6.proto != 'none')
|
||||
{
|
||||
var s = String.format(
|
||||
'<strong><%:Address%>: </strong>%s<br />' +
|
||||
'<strong><%:Gateway%>: </strong>%s<br />',
|
||||
(ifc6.ip6addr) ? ifc6.ip6addr : '::',
|
||||
(ifc6.gw6addr) ? ifc6.gw6addr : '::'
|
||||
);
|
||||
|
||||
for (var i = 0; i < ifc6.dns.length; i++)
|
||||
{
|
||||
s += String.format(
|
||||
'<strong><%:DNS%> %d: </strong>%s<br />',
|
||||
i + 1, ifc6.dns[i]
|
||||
);
|
||||
}
|
||||
|
||||
if (ifc6.uptime > 0)
|
||||
{
|
||||
s += String.format(
|
||||
'<strong><%:Connected%>: </strong>%t<br />',
|
||||
ifc6.uptime
|
||||
);
|
||||
}
|
||||
|
||||
ss6.innerHTML = String.format('<small>%s</small>', s);
|
||||
si6.innerHTML = String.format(
|
||||
'<a href="%s"><img src="<%=resource%>/icons/ethernet.png" /></a>' +
|
||||
'<br /><small>%s</small>', ifc6.link, ifc6.ifname
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
si6.innerHTML = '<img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small>';
|
||||
ss6.innerHTML = '<em>Not connected</em>';
|
||||
}
|
||||
|
||||
var e;
|
||||
|
||||
if (e = document.getElementById('localtime'))
|
||||
e.innerHTML = info.localtime;
|
||||
|
||||
if (e = document.getElementById('uptime'))
|
||||
e.innerHTML = String.format('%t', info.uptime);
|
||||
|
||||
if (e = document.getElementById('loadavg'))
|
||||
e.innerHTML = String.format('%.02f, %.02f, %.02f',
|
||||
info.loadavg[0], info.loadavg[1], info.loadavg[2]);
|
||||
|
||||
if (e = document.getElementById('memtotal'))
|
||||
e.innerHTML = progressbar(
|
||||
(info.memfree + info.membuffers + info.memcached) + " kB",
|
||||
info.memtotal + " kB"
|
||||
);
|
||||
|
||||
if (e = document.getElementById('memfree'))
|
||||
e.innerHTML = progressbar(
|
||||
info.memfree + " kB", info.memtotal + " kB"
|
||||
);
|
||||
|
||||
if (e = document.getElementById('memcache'))
|
||||
e.innerHTML = progressbar(
|
||||
info.memcached + " kB", info.memtotal + " kB"
|
||||
);
|
||||
|
||||
if (e = document.getElementById('membuff'))
|
||||
e.innerHTML = progressbar(
|
||||
info.membuffers + " kB", info.memtotal + " kB"
|
||||
);
|
||||
|
||||
if (e = document.getElementById('conns'))
|
||||
e.innerHTML = progressbar(
|
||||
info.conncount + " kB", info.connmax + " kB"
|
||||
);
|
||||
|
||||
window.setTimeout(update_status, 5000);
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
update_status();
|
||||
//]]></script>
|
||||
|
||||
<h2><a id="content" name="content"><%:Status%></a></h2>
|
||||
<p><%_Here you can find information about the current system status like <abbr title="Central Processing Unit">CPU</abbr> clock frequency, memory usage or network interface data.%></p>
|
||||
<p><%:Also kernel or service logfiles can be viewed here to get an overview over their current state.%></p>
|
||||
<%+footer%>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:System%></legend>
|
||||
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="33%"><%:Router Name%></td><td><%=luci.sys.hostname() or "?"%></td></tr>
|
||||
<tr><td width="33%"><%:Router Model%></td><td><%=pcdata(model or "?")%></td></tr>
|
||||
<tr><td width="33%"><%:Firmware Version%></td><td>
|
||||
<%=pcdata(luci.version.distname)%> <%=pcdata(luci.version.distversion)%> /
|
||||
<%=pcdata(luci.version.luciname)%> <%=pcdata(luci.version.luciversion)%>
|
||||
</td></tr>
|
||||
<tr><td width="33%"><%:Kernel%></td><td><%=luci.sys.exec("uname -r")%></td></tr>
|
||||
<tr><td width="33%"><%:Local Time%></td><td id="localtime">-</td></tr>
|
||||
<tr><td width="33%"><%:Uptime%></td><td id="uptime">-</td></tr>
|
||||
<tr><td width="33%"><%:Load Average%></td><td id="loadavg">-</td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:CPU%></legend>
|
||||
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="33%"><%:CPU Model%></td><td><%=system or "?" %></td></tr>
|
||||
<tr><td width="33%"><%:CPU Speed%></td><td><%=math.floor((bogomips + 5) / 10) * 10 %> MHz</td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Memory%></legend>
|
||||
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="33%"><%:Total Available%></td><td id="memtotal">-</td></tr>
|
||||
<tr><td width="33%"><%:Free%></td><td id="memfree">-</td></tr>
|
||||
<tr><td width="33%"><%:Cached%></td><td id="memcache">-</td></tr>
|
||||
<tr><td width="33%"><%:Buffered%></td><td id="membuff">-</td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Network%></legend>
|
||||
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="33%" style="vertical-align:top"><%:IPv4 WAN Status%></td><td>
|
||||
<table><tr>
|
||||
<td id="wan4_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
|
||||
<td id="wan4_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
|
||||
</tr></table>
|
||||
</td></tr>
|
||||
<tr><td width="33%" style="vertical-align:top"><%:IPv6 WAN Status%></td><td>
|
||||
<table><tr>
|
||||
<td id="wan6_i" style="width:16px; text-align:center; padding:3px"><img src="<%=resource%>/icons/ethernet_disabled.png" /><br /><small>?</small></td>
|
||||
<td id="wan6_s" style="vertical-align:middle; padding: 3px"><em><%:Collecting data...%></em></td>
|
||||
</tr></table>
|
||||
</td></tr>
|
||||
<tr><td width="33%"><%:Active IP Connections%></td><td id="conns">-</td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<%+footer%>
|
||||
|
|
Loading…
Reference in a new issue