summaryrefslogtreecommitdiffhomepage
path: root/module/rpc-core
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-04-27 16:12:24 +0000
committerSteven Barth <steven@midlink.org>2008-04-27 16:12:24 +0000
commitbba585f063ccc1e483346c9b5625d4dcf84d6586 (patch)
treeab369d260f321d1529a15c0a36b60e7e465fe8ae /module/rpc-core
parent1b159023db95ec0d429f1fc71536ef96edc37333 (diff)
* Added initial version of RPC info API
* Fixed client splash
Diffstat (limited to 'module/rpc-core')
-rw-r--r--module/rpc-core/Makefile35
-rw-r--r--module/rpc-core/src/controller/rpc/luciinfo.lua35
2 files changed, 70 insertions, 0 deletions
diff --git a/module/rpc-core/Makefile b/module/rpc-core/Makefile
new file mode 100644
index 000000000..113799af6
--- /dev/null
+++ b/module/rpc-core/Makefile
@@ -0,0 +1,35 @@
+LUAC = luac
+LUAC_OPTIONS = -s
+
+FILES = i18n/* view/*/*.htm
+
+CFILES = controller/*/*.lua model/cbi/*/*.lua model/menu/*.lua
+
+DIRECTORIES = model/cbi model/menu controller i18n view
+
+
+INFILES = $(CFILES:%=src/%)
+OUTDIRS = $(DIRECTORIES:%=dist/%)
+CPFILES = $(FILES:%=src/%)
+
+.PHONY: all compile source clean depends
+
+all: compile
+
+
+depends:
+ mkdir -p $(OUTDIRS)
+ for i in $(CPFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
+ mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
+
+compile: depends
+ for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
+ mkdir -p dist/$$(dirname $$i); $(LUAC) $(LUAC_OPTIONS) -o dist/$$i src/$$i; fi; done
+
+source: depends
+ for i in $(INFILES); do if [ -f "$$i" ]; then i=$$(echo $$i | cut -d/ -f2-); \
+ mkdir -p dist/$$(dirname $$i); cp src/$$i dist/$$i; fi; done
+
+
+clean:
+ rm dist -rf
diff --git a/module/rpc-core/src/controller/rpc/luciinfo.lua b/module/rpc-core/src/controller/rpc/luciinfo.lua
new file mode 100644
index 000000000..8d10fa885
--- /dev/null
+++ b/module/rpc-core/src/controller/rpc/luciinfo.lua
@@ -0,0 +1,35 @@
+module("ffluci.controller.rpc.luciinfo", package.seeall)
+
+function action_index()
+ local uci = ffluci.model.uci.StateSession()
+
+ ffluci.http.textheader()
+
+ -- General
+ print("luciinfo.api=1")
+ print("luciinfo.version=" .. tostring(ffluci.__version__))
+
+ -- Sysinfo
+ local s, m, r = ffluci.sys.sysinfo()
+ local dr = ffluci.sys.net.defaultroute()
+ dr = dr and ffluci.sys.net.hexip4(dr.Gateway) or ""
+ local l1, l5, l15 = ffluci.sys.loadavg()
+
+ print("sysinfo.system=" .. sanitize(s))
+ print("sysinfo.cpu=" .. sanitize(m))
+ print("sysinfo.ram=" .. sanitize(r))
+ print("sysinfo.hostname=" .. sanitize(ffluci.sys.hostname()))
+ print("sysinfo.load1=" .. tostring(l1))
+ print("sysinfo.load5=" .. tostring(l5))
+ print("sysinfo.load15=" .. tostring(l15))
+ print("sysinfo.defaultgw=" .. dr)
+
+
+ -- Freifunk
+ local ff = uci:show("freifunk", true) or ""
+ print(ff)
+end
+
+function sanitize(val)
+ return val:gsub("\n", "\t")
+end \ No newline at end of file