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