352008e30de38ed75c068da4c0e1f318cddd5f54
[project/luci.git] / modules / admin-mini / luasrc / model / cbi / mini / index.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5
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
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13 ]]--
14 require("luci.sys")
15 require("luci.tools.webadmin")
16
17 w = Template("mini/index")
18
19 f = SimpleForm("main", translate("system"))
20 f.reset = false
21 f.submit = false
22
23 local system, model, memtotal, memcached, membuffers, memfree = luci.sys.sysinfo()
24 local uptime = luci.sys.uptime()
25 f:field(DummyValue, "_system", translate("system")).value = system
26 f:field(DummyValue, "_cpu", translate("m_i_processor")).value = model
27
28 local load1, load5, load15 = luci.sys.loadavg()
29 f:field(DummyValue, "_la", translate("load")).value = 
30  string.format("%.2f, %.2f, %.2f", load1, load5, load15)
31  
32 f:field(DummyValue, "_memtotal", translate("m_i_memory")).value = 
33  string.format("%.2f MB (%.0f%% %s, %.0f%% %s, %.0f%% %s)",
34   tonumber(memtotal) / 1024,
35   100 * memcached / memtotal,
36   translate("mem_cached") or "",
37   100 * membuffers / memtotal,
38   translate("mem_buffered") or "",
39   100 * memfree / memtotal,
40   translate("mem_free") or "")
41
42 f:field(DummyValue, "_systime", translate("m_i_systemtime")).value =
43  os.date("%c")
44  
45 f:field(DummyValue, "_uptime", translate("m_i_uptime")).value = 
46  luci.tools.webadmin.date_format(tonumber(uptime))
47
48 return w, f