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
14 require("luci.http.protocol.date")
16 require("luci.tools.webadmin")
18 m = Map("system", translate("system"), translate("a_s_desc"))
20 s = m:section(TypedSection, "system", "")
23 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
24 local uptime = luci.sys.uptime()
26 s:option(DummyValue, "_system", translate("system")).value = system
27 s:option(DummyValue, "_cpu", translate("m_i_processor")).value = model
29 local load1, load5, load15 = luci.sys.loadavg()
30 s:option(DummyValue, "_la", translate("load")).value =
31 string.format("%.2f, %.2f, %.2f", load1, load5, load15)
33 s:option(DummyValue, "_memtotal", translate("m_i_memory")).value =
34 string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
35 tonumber(memtotal) / 1024,
36 100 * memcached / memtotal,
37 translate("mem_cached") or "",
38 100 * membuffers / memtotal,
39 translate("mem_buffered") or "",
40 100 * memfree / memtotal,
41 translate("mem_free") or "")
43 s:option(DummyValue, "_systime", translate("m_i_systemtime")).value =
46 s:option(DummyValue, "_uptime", translate("m_i_uptime")).value =
47 luci.tools.webadmin.date_format(tonumber(uptime))
49 s:option(Value, "hostname", translate("hostname"))
51 tz = s:option(ListValue, "timezone", translate("timezone"))
52 for k, offset in luci.util.vspairs(luci.http.protocol.date.TZ) do
53 local zone = k:upper()
54 local osgn = (offset >= 0 and "" or "+")
55 local ohrs = math.floor(-offset / 3600)
56 local omin = (offset % 3600) / 60
58 local ptz = zone .. osgn .. (ohrs ~= 0 and ohrs or "") .. (omin ~= 0 and ":" .. omin or "")
59 local dtz = string.format("%+03d:%02d ", ohrs, omin) .. zone
64 s:option(Value, "log_size", nil, "kiB").optional = true
65 s:option(Value, "log_ip").optional = true
66 s:option(Value, "conloglevel").optional = true