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("Here you can configure the basic aspects of your device like its hostname or the timezone."))
21 s = m:section(TypedSection, "system", "")
25 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
26 local uptime = luci.sys.uptime()
28 s:option(DummyValue, "_system", translate("System")).value = system
29 s:option(DummyValue, "_cpu", translate("Processor")).value = model
31 local load1, load5, load15 = luci.sys.loadavg()
32 s:option(DummyValue, "_la", translate("Load")).value =
33 string.format("%.2f, %.2f, %.2f", load1, load5, load15)
35 s:option(DummyValue, "_memtotal", translate("Memory")).value =
36 string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
37 tonumber(memtotal) / 1024,
38 100 * memcached / memtotal,
39 tostring(translate("cached")),
40 100 * membuffers / memtotal,
41 tostring(translate("buffered")),
42 100 * memfree / memtotal,
43 tostring(translate("free"))
46 s:option(DummyValue, "_systime", translate("Local Time")).value =
49 s:option(DummyValue, "_uptime", translate("Uptime")).value =
50 luci.tools.webadmin.date_format(tonumber(uptime))
52 hn = s:option(Value, "hostname", translate("Hostname"))
54 function hn.write(self, section, value)
55 Value.write(self, section, value)
56 luci.sys.hostname(value)
60 tz = s:option(ListValue, "zonename", translate("Timezone"))
63 for i, zone in ipairs(luci.sys.zoneinfo.TZ) do
67 function tz.write(self, section, value)
68 local function lookup_zone(title)
69 for _, zone in ipairs(luci.sys.zoneinfo.TZ) do
70 if zone[1] == title then return zone[2] end
74 AbstractValue.write(self, section, value)
75 self.map.uci:set("system", section, "timezone", lookup_zone(value) or "GMT0")
78 s:option(Value, "log_size", nil, "kiB").optional = true
79 s:option(Value, "log_ip").optional = true
80 s:option(Value, "conloglevel").optional = true
81 s:option(Value, "cronloglevel").optional = true