2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
16 require("luci.sys.zoneinfo")
17 require("luci.tools.webadmin")
20 m = Map("system", translate("system"), translate("a_s_desc"))
22 s = m:section(TypedSection, "system", "")
27 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
28 local uptime = luci.sys.uptime()
30 s:option(DummyValue, "_system", translate("system")).value = system
31 s:option(DummyValue, "_cpu", translate("m_i_processor")).value = model
33 local load1, load5, load15 = luci.sys.loadavg()
34 s:option(DummyValue, "_la", translate("load")).value =
35 string.format("%.2f, %.2f, %.2f", load1, load5, load15)
37 s:option(DummyValue, "_memtotal", translate("m_i_memory")).value =
38 string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
39 tonumber(memtotal) / 1024,
40 100 * memcached / memtotal,
41 translate("mem_cached") or "",
42 100 * membuffers / memtotal,
43 translate("mem_buffered") or "",
44 100 * memfree / memtotal,
45 translate("mem_free") or "")
47 s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
50 s:option(DummyValue, "_uptime", translate("m_i_uptime")).value =
51 luci.tools.webadmin.date_format(tonumber(uptime))
53 s:option(Value, "hostname", translate("hostname"))
55 tz = s:option(ListValue, "zonename", translate("timezone"))
58 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
62 function tz.write(self, section, value)
63 local function lookup_zone(title)
64 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
65 if zone[1] == title then return zone[2] end
69 AbstractValue.write(self, section, value)
70 self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")