From 64d0031233a7e1b7e4df71953bc0fa72462e6bf5 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 15 Jan 2015 14:11:35 +0100 Subject: luci-mod-freifunk: eliminate uses of luci.sys.sysinfo() Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/freifunk/public_status.htm | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'modules/luci-mod-freifunk/luasrc/view') diff --git a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm index 10bd849d7d..715ac756fd 100644 --- a/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm +++ b/modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm @@ -1,33 +1,37 @@ <% +local utl = require "luci.util" local sys = require "luci.sys" local twa = require "luci.tools.webadmin" -- System -local model, system, memtotal, memcached, membuffers, memfree, bogomips = sys.sysinfo() -local uptime = twa.date_format(tonumber(sys.uptime())) + +local sysinfo = utl.ubus("system", "info") or { } +local boardinfo = utl.ubus("system", "board") or { } + +local loads = sysinfo.load or { 0, 0, 0 } +local meminfo = sysinfo.memory or { + total = 0, + free = 0, + buffered = 0, + shared = 0 +} + +local uptime = twa.date_format(sysinfo.uptime or 0) local time = os.date("%a, %d %b %Y, %H:%M:%S") -local load1, load5, load15 = sys.loadavg() -local load = string.format("%.2f, %.2f, %.2f", load1, load5, load15) +local load = string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0) local mem = string.format( - "%.2f MB (%.2f %s, %.2f %s, %.2f %s, %.2f %s)", - tonumber(memtotal) / 1024, - tonumber(memtotal - memfree) / 1024, + "%.2f MB (%.2f %s, %.2f %s, %.2f %s)", + memory.total / 1024 / 1024, + (memory.total - memory.free) / 1024 / 1024, tostring(i18n.translate("used")), - memfree / 1024, + memory.free / 1024 / 1024, tostring(i18n.translate("free")), - memcached / 1024, - tostring(i18n.translate("cached")), - membuffers / 1024, + memory.buffered / 1024 / 1024, tostring(i18n.translate("buffered")) ) --- update interval -local bogomips = bogomips or 100 -local interval = 10 -if bogomips > 350 then - interval = 5 -end +local interval = 5 -- wireless local ntm = require "luci.model.network".init() @@ -230,8 +234,8 @@ end

<%:System%>

-
<%=system%>
-
<%=model%>
+
<%=boardinfo.system or "?"%>
+
<%=boardinfo.model or "?"%>
<%=load%>
<%=mem%>
<%=time%>
-- cgit v1.2.3