require("luci.sys")
require("luci.sys.zoneinfo")
require("luci.tools.webadmin")
+require("luci.util")
m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
s.addremove = false
-local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
-local uptime = luci.sys.uptime()
+local sysinfo = luci.util.ubus("system", "info") or { }
+local boardinfo = luci.util.ubus("system", "board") or { }
-s:option(DummyValue, "_system", translate("System")).value = model
-s:option(DummyValue, "_cpu", translate("Processor")).value = system
+local uptime = sysinfo.uptime or 0
+local loads = sysinfo.load or { 0, 0, 0 }
+local memory = sysinfo.memory or {
+ total = 0,
+ free = 0,
+ buffered = 0,
+ shared = 0
+}
+
+s:option(DummyValue, "_system", translate("Model")).value = boardinfo.model or "?"
+s:option(DummyValue, "_cpu", translate("System")).value = boardinfo.system or "?"
-local load1, load5, load15 = luci.sys.loadavg()
s:option(DummyValue, "_la", translate("Load")).value =
- string.format("%.2f, %.2f, %.2f", load1, load5, load15)
+ string.format("%.2f, %.2f, %.2f", loads[1] / 65535.0, loads[2] / 65535.0, loads[3] / 65535.0)
s:option(DummyValue, "_memtotal", translate("Memory")).value =
- string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
- tonumber(memtotal) / 1024,
- 100 * memcached / memtotal,
- tostring(translate("cached")),
- 100 * membuffers / memtotal,
+ string.format("%.2f MB (%.0f%% %s, %.0f%% %s)",
+ tonumber(memory.total) / 1024 / 1024,
+ 100 * memory.buffered / memory.total,
tostring(translate("buffered")),
- 100 * memfree / memtotal,
+ 100 * memory.free / memory.total,
tostring(translate("free"))
)