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")
19 m = Map("system", translate("system"), translate("a_s_desc"))
21 s = m:section(TypedSection, "system", "")
24 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
25 local uptime = luci.sys.uptime()
27 s:option(DummyValue, "_system", translate("system")).value = system
28 s:option(DummyValue, "_cpu", translate("m_i_processor")).value = model
30 local load1, load5, load15 = luci.sys.loadavg()
31 s:option(DummyValue, "_la", translate("load")).value =
32 string.format("%.2f, %.2f, %.2f", load1, load5, load15)
34 s:option(DummyValue, "_memtotal", translate("m_i_memory")).value =
35 string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
36 tonumber(memtotal) / 1024,
37 100 * memcached / memtotal,
38 tostring(translate("mem_cached", "")),
39 100 * membuffers / memtotal,
40 tostring(translate("mem_buffered", "")),
41 100 * memfree / memtotal,
42 tostring(translate("mem_free", ""))
45 s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
48 s:option(DummyValue, "_uptime", translate("m_i_uptime")).value =
49 luci.tools.webadmin.date_format(tonumber(uptime))
51 hn = s:option(Value, "hostname", translate("hostname"))
53 function hn.write(self, section, value)
54 Value.write(self, section, value)
55 luci.sys.hostname(value)
59 tz = s:option(ListValue, "zonename", translate("timezone"))
62 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
66 function tz.write(self, section, value)
67 local function lookup_zone(title)
68 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
69 if zone[1] == title then return zone[2] end
73 AbstractValue.write(self, section, value)
74 self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")
77 s:option(Value, "log_size", nil, "kiB").optional = true
78 s:option(Value, "log_ip").optional = true
79 s:option(Value, "conloglevel").optional = true
80 s:option(Value, "cronloglevel").optional = true