summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-admin-full/luasrc/view
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-01-15 13:35:10 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-15 13:35:10 +0100
commit46beca9fb15695a5c576093bb24a88120e155972 (patch)
tree7d876f0e90350d4b0865b1b13421cfde1024a54e /modules/luci-mod-admin-full/luasrc/view
parent0b491a05ca1dde902586c8c13fc3a9fa38fdb3bb (diff)
luci-mod-admin-full: eliminate the use of luci.sys.sysinfo()
Fetch the required information via ubus instead of relying on the to-be-removed luci.sys.sysinfo() and luci.sys.loadavg() functions. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-mod-admin-full/luasrc/view')
-rw-r--r--modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm81
1 files changed, 40 insertions, 41 deletions
diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
index cfeb91ac7..cb6371bfa 100644
--- a/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
+++ b/modules/luci-mod-admin-full/luasrc/view/admin_status/index.htm
@@ -19,11 +19,22 @@ You may obtain a copy of the License at
local has_dhcp = luci.fs.access("/etc/config/dhcp")
local has_wifi = luci.fs.stat("/etc/config/wireless")
has_wifi = has_wifi and has_wifi.size > 0
- local _, _, memtotal, memcached, membuffers, memfree, _, swaptotal, swapcached, swapfree = luci.sys.sysinfo()
- local has_swap
- if swaptotal > 0 then
- has_swap = 1
- end
+
+ local sysinfo = luci.util.ubus("system", "info") or { }
+ local boardinfo = luci.util.ubus("system", "board") or { }
+
+ local meminfo = sysinfo.memory or {
+ total = 0,
+ free = 0,
+ buffered = 0,
+ shared = 0
+ }
+
+ local swapinfo = sysinfo.swap or {
+ total = 0,
+ free = 0
+ }
+
local has_dsl = luci.fs.stat("/etc/init.d/dsl_control")
if luci.http.formvalue("status") == "1" then
@@ -42,16 +53,11 @@ You may obtain a copy of the License at
""):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,
- swaptotal = swaptotal,
- swapcached = swapcached,
- swapfree = swapfree,
+ uptime = sysinfo.uptime or 0,
+ localtime = sysinfo.localtime or 0,
+ loadavg = sysinfo.load or { 0, 0, 0 },
+ memory = meminfo,
+ swap = swapinfo,
connmax = conn_max,
conncount = conn_count,
leases = luci.tools.status.dhcp_leases(),
@@ -95,8 +101,6 @@ You may obtain a copy of the License at
return
end
-
- local system, model = luci.sys.sysinfo()
-%>
<%+header%>
@@ -501,50 +505,47 @@ You may obtain a copy of the License at
var e;
if (e = document.getElementById('localtime'))
- e.innerHTML = info.localtime;
+ e.innerHTML = (new Date(info.localtime * 1000)).toUTCString();
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]);
+ e.innerHTML = String.format(
+ '%.02f, %.02f, %.02f',
+ info.loadavg[0] / 65535.0,
+ info.loadavg[1] / 65535.0,
+ info.loadavg[2] / 65535.0
+ );
if (e = document.getElementById('memtotal'))
e.innerHTML = progressbar(
- (info.memfree + info.membuffers + info.memcached) + " <%:kB%>",
- info.memtotal + " <%:kB%>"
+ ((info.memory.free + info.memory.buffered) / 1024) + " <%:kB%>",
+ (info.memory.total / 1024) + " <%: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%>"
+ (info.memory.free / 1024) + " <%:kB%>",
+ (info.memory.total / 1024) + " <%:kB%>"
);
if (e = document.getElementById('membuff'))
e.innerHTML = progressbar(
- info.membuffers + " <%:kB%>", info.memtotal + " <%:kB%>"
- );
-
- if (e = document.getElementById('swapcache'))
- e.innerHTML = progressbar(
- info.swapcached + " <%:kB%>", info.swaptotal + " <%:kB%>"
+ (info.memory.buffered / 1024) + " <%:kB%>",
+ (info.memory.total / 1024) + " <%:kB%>"
);
if (e = document.getElementById('swaptotal'))
e.innerHTML = progressbar(
- (info.swapfree + info.swapcached) + " <%:kB%>",
- info.swaptotal + " <%:kB%>"
+ (info.swap.free / 1024) + " <%:kB%>",
+ (info.swap.total / 1024) + " <%:kB%>"
);
if (e = document.getElementById('swapfree'))
e.innerHTML = progressbar(
- info.swapfree + " <%:kB%>", info.swaptotal + " <%:kB%>"
+ (info.swap.free / 1024) + " <%:kB%>",
+ (info.swap.total / 1024) + " <%:kB%>"
);
if (e = document.getElementById('conns'))
@@ -561,7 +562,7 @@ You may obtain a copy of the License at
<table width="100%" cellspacing="10">
<tr><td width="33%"><%:Hostname%></td><td><%=luci.sys.hostname() or "?"%></td></tr>
- <tr><td width="33%"><%:Model%></td><td><%=pcdata(model or "?")%></td></tr>
+ <tr><td width="33%"><%:Model%></td><td><%=pcdata(boardinfo.model or boardinfo.system 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)%>)
@@ -579,19 +580,17 @@ You may obtain a copy of the License at
<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>
-<% if has_swap then %>
+<% if swapinfo.total > 0 then %>
<fieldset class="cbi-section">
<legend><%:Swap%></legend>
<table width="100%" cellspacing="10">
<tr><td width="33%"><%:Total Available%></td><td id="swaptotal">-</td></tr>
<tr><td width="33%"><%:Free%></td><td id="swapfree">-</td></tr>
- <tr><td width="33%"><%:Cached%></td><td id="swapcache">-</td></tr>
</table>
</fieldset>
<% end %>