* Core translation
[project/luci.git] / modules / freifunk / luasrc / controller / freifunk / luciinfo.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 module("luci.controller.freifunk.luciinfo", package.seeall)
15
16 function index()
17         node("freifunk", "luciinfo").target = call("action_index")
18 end
19
20 function action_index()
21         local uci = luci.model.uci
22         luci.http.prepare_content("text/plain")
23         
24         -- General
25         print("luciinfo.api=1")
26         print("luciinfo.version=" .. tostring(require("luci").__version__))
27         
28         -- Sysinfo
29         local s, m, r = luci.sys.sysinfo()
30         local dr = luci.sys.net.defaultroute()
31         dr = dr and luci.sys.net.hexip4(dr.Gateway) or ""
32         local l1, l5, l15 = luci.sys.loadavg()
33         
34         print("sysinfo.system=" .. sanitize(s))
35         print("sysinfo.cpu=" .. sanitize(m))
36         print("sysinfo.ram=" .. sanitize(r))
37         print("sysinfo.hostname=" .. sanitize(luci.sys.hostname()))
38         print("sysinfo.load1=" .. tostring(l1))
39         print("sysinfo.load5=" .. tostring(l5))
40         print("sysinfo.load15=" .. tostring(l15))
41         print("sysinfo.defaultgw=" .. dr)
42
43         
44         -- Freifunk
45         local ff = uci.get_all("freifunk") or {}
46         for k, v in pairs(ff) do
47                         for i, j in pairs(v) do
48                                 if i:sub(1, 1) ~= "." then
49                                         print("freifunk." .. k .. "." .. i .. "=" .. j)
50                                 end
51                         end
52         end
53 end
54
55 function sanitize(val)
56         return val:gsub("\n", "\t")
57 end