summaryrefslogtreecommitdiffstats
path: root/health-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-10-17 19:07:53 +0000
committerTed Trask <ttrask01@yahoo.com>2013-10-17 19:07:53 +0000
commit2ece009273252437281c8cc0b84ba2ec49e5d07c (patch)
tree1c082ee4891a4717f2fea09f0df4a8946d9fdb41 /health-model.lua
parent0537a242f9709271454252e7897a7709144a3b02 (diff)
downloadacf-alpine-baselayout-2ece009273252437281c8cc0b84ba2ec49e5d07c.tar.bz2
acf-alpine-baselayout-2ece009273252437281c8cc0b84ba2ec49e5d07c.tar.xz
Remove all calls to 'module' in preparation for move to Lua 5.2
Use mymodule parameter for module definition. This was also helpful in revealing places where the code relied on the global environment.
Diffstat (limited to 'health-model.lua')
-rw-r--r--health-model.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/health-model.lua b/health-model.lua
index 50c61f2..424a0e4 100644
--- a/health-model.lua
+++ b/health-model.lua
@@ -1,5 +1,5 @@
-- acf model for displaying logfiles recusivly
-module (..., package.seeall)
+local mymodule = {}
fs = require("acf.fs")
date = require("acf.date")
@@ -52,7 +52,7 @@ end
-- ###############################################################
-- Public functions
-get_system = function (self)
+mymodule.get_system = function (self)
local system = {}
local meminfo = memusage()
system.uptime = cfe({ value=querycmd("uptime"), label="Uptime" })
@@ -68,7 +68,7 @@ get_system = function (self)
return cfe({ type="group", value=system })
end
-get_storage = function (self)
+mymodule.get_storage = function (self)
local storage = {}
local disk = diskfree() .. "\n"
local other = {}
@@ -108,7 +108,7 @@ get_storage = function (self)
return cfe({ type="group", value=storage })
end
-get_network = function (self)
+mymodule.get_network = function (self)
local network = {}
network.interfaces = cfe({ value=querycmd("ip addr"), label="Interfaces" })
network.routes = cfe({ value=querycmd("ip route"), label="Routes" })
@@ -116,14 +116,14 @@ get_network = function (self)
return cfe({ type="group", value=network })
end
-get_proc = function (self)
+mymodule.get_proc = function (self)
local proc = {}
proc.processor = cfe({ value=fs.read_file("/proc/cpuinfo") or "", label="Processor" })
proc.memory = cfe({ value=fs.read_file("/proc/meminfo") or "", label="Memory" })
return cfe({ type="group", value=proc })
end
-get_networkstats = function ()
+mymodule.get_networkstats = function ()
local stats = cfe({ type="structure", value={}, label="Network Stats", timestamp=os.time() })
local result = fs.read_file("/proc/net/dev") or ""
-- parse the result
@@ -144,3 +144,5 @@ get_networkstats = function ()
end
return stats
end
+
+return mymodule