summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-freifunk
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-01-15 14:11:35 +0100
committerJo-Philipp Wich <jow@openwrt.org>2015-01-15 14:11:35 +0100
commit64d0031233a7e1b7e4df71953bc0fa72462e6bf5 (patch)
tree1551cacf8b51298bebec7280416c2a053965d52a /modules/luci-mod-freifunk
parenta1f67784c9ef2a95facba658fce6ae57a795758c (diff)
luci-mod-freifunk: eliminate uses of luci.sys.sysinfo()
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-mod-freifunk')
-rw-r--r--modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua36
-rw-r--r--modules/luci-mod-freifunk/luasrc/view/freifunk/public_status.htm42
2 files changed, 55 insertions, 23 deletions
diff --git a/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua
index d4606e750..bb58a3f10 100644
--- a/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua
+++ b/modules/luci-mod-freifunk/luasrc/controller/freifunk/freifunk.lua
@@ -139,14 +139,42 @@ function jsonstatus()
local ffznet = ffzone and cursor:get("firewall", ffzone, "network")
local ffwifs = ffznet and util.split(ffznet, " ") or {}
+ local sysinfo = util.ubus("system", "info") or { }
+ local boardinfo = util.ubus("system", "board") or { }
+
+ local loads = sysinfo.load or { 0, 0, 0 }
+
+ local memory = sysinfo.memory or {
+ total = 0,
+ free = 0,
+ shared = 0,
+ buffered = 0
+ }
+
+ local swap = sysinfo.swap or {
+ total = 0,
+ free = 0
+ }
+
root.protocol = 1
root.system = {
- uptime = {sys.uptime()},
- loadavg = {sys.loadavg()},
- sysinfo = {sys.sysinfo()},
- hostname = sys.hostname()
+ uptime = { sysinfo.uptime or 0 },
+ loadavg = { loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0 },
+ sysinfo = {
+ boardinfo.system or "?",
+ boardinfo.model or "?",
+ memory.total,
+ 0, -- former cached memory
+ memory.buffered,
+ memory.free,
+ 0, -- former bogomips
+ swap.total,
+ 0, -- former cached swap
+ swap.free
+ },
+ hostname = boardinfo.hostname
}
root.firmware = {
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 10bd849d7..715ac756f 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
<div class="cbi-map">
<h2><%:System%></h2>
<div class="cbi-section-node">
- <div class="cbi-value"><label class="cbi-value-title"><%:System%></label><div class="cbi-value-field"><%=system%></div></div>
- <div class="cbi-value"><label class="cbi-value-title"><%:Processor%></label><div class="cbi-value-field"><%=model%></div></div>
+ <div class="cbi-value"><label class="cbi-value-title"><%:System%></label><div class="cbi-value-field"><%=boardinfo.system or "?"%></div></div>
+ <div class="cbi-value"><label class="cbi-value-title"><%:Model%></label><div class="cbi-value-field"><%=boardinfo.model or "?"%></div></div>
<div class="cbi-value"><label class="cbi-value-title"><%:Load%></label><div class="cbi-value-field" id="dynload"><%=load%></div></div>
<div class="cbi-value"><label class="cbi-value-title"><%:Memory%></label><div class="cbi-value-field" id="dynmem"><%=mem%></div></div>
<div class="cbi-value"><label class="cbi-value-title"><%:Local Time%></label><div class="cbi-value-field" id="dyntime"><%=time%></div></div>