From: Jo-Philipp Wich Date: Thu, 15 Jan 2015 12:35:10 +0000 (+0100) Subject: luci-mod-admin-full: eliminate the use of luci.sys.sysinfo() X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=46beca9fb15695a5c576093bb24a88120e155972 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 --- 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 - +
<%:Hostname%><%=luci.sys.hostname() or "?"%>
<%:Model%><%=pcdata(model or "?")%>
<%:Model%><%=pcdata(boardinfo.model or boardinfo.system or "?")%>
<%:Firmware Version%> <%=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 -
<%:Total Available%>-
<%:Free%>-
<%:Cached%>-
<%:Buffered%>-
-<% if has_swap then %> +<% if swapinfo.total > 0 then %>
<%:Swap%> -
<%:Total Available%>-
<%:Free%>-
<%:Cached%>-
<% end %>