(no commit message)
[project/luci.git] / module / rpc-core / src / controller / rpc / luciinfo.lua
1 module("ffluci.controller.rpc.luciinfo", package.seeall)
2
3 function action_index()
4 local uci = ffluci.model.uci.StateSession()
5
6 ffluci.http.prepare_content("text/plain")
7
8 -- General
9 print("luciinfo.api=1")
10 print("luciinfo.version=" .. tostring(ffluci.__version__))
11
12 -- Sysinfo
13 local s, m, r = ffluci.sys.sysinfo()
14 local dr = ffluci.sys.net.defaultroute()
15 dr = dr and ffluci.sys.net.hexip4(dr.Gateway) or ""
16 local l1, l5, l15 = ffluci.sys.loadavg()
17
18 print("sysinfo.system=" .. sanitize(s))
19 print("sysinfo.cpu=" .. sanitize(m))
20 print("sysinfo.ram=" .. sanitize(r))
21 print("sysinfo.hostname=" .. sanitize(ffluci.sys.hostname()))
22 print("sysinfo.load1=" .. tostring(l1))
23 print("sysinfo.load5=" .. tostring(l5))
24 print("sysinfo.load15=" .. tostring(l15))
25 print("sysinfo.defaultgw=" .. dr)
26
27
28 -- Freifunk
29 local ff = uci:sections("freifunk") or {}
30 for k, v in pairs(ff) do
31 if k:sub(1, 1) ~= "." then
32 for i, j in pairs(v) do
33 print("freifunk." .. k .. "." .. i .. "=" .. j)
34 end
35 end
36 end
37 end
38
39 function sanitize(val)
40 return val:gsub("\n", "\t")
41 end