diff options
author | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2009-01-13 16:01:06 +0000 |
commit | 5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973 (patch) | |
tree | 89b5c319d2f14352e25260d5fbf3ec67f85ca636 /health-model.lua | |
parent | 9dfc491513676fa005f68cc764c4db37f0b3094f (diff) | |
download | acf-alpine-baselayout-5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973.tar.bz2 acf-alpine-baselayout-5ec7a43c6f0a6cd1369da101fa0e3f1f12d99973.tar.xz |
Modified fs.lua to survive nil parameters. Added create_directory and used within create_file and write_file. Reviewed each read_file call to make sure handles nil return value.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1677 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'health-model.lua')
-rw-r--r-- | health-model.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/health-model.lua b/health-model.lua index 641a804..e012bf1 100644 --- a/health-model.lua +++ b/health-model.lua @@ -71,7 +71,7 @@ get_storage = function (self) storage.hd.value[name].used = string.match(line, name.."%s*%S*%s*%S*%s*%S*%s*(%S*)%%") end end - storage.partitions = cfe({ value=fs.read_file("/proc/partitions"), label="Partitions" }) + storage.partitions = cfe({ value=fs.read_file("/proc/partitions") or "", label="Partitions" }) return cfe({ type="group", value=storage }) end @@ -90,14 +90,14 @@ end get_proc = function (self) local proc = {} - proc.processor = cfe({ value=fs.read_file("/proc/cpuinfo"), label="Processor" }) - proc.memory = cfe({ value=fs.read_file("/proc/meminfo"), label="Memory" }) + 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 () local stats = cfe({ type="structure", value={}, label="Network Stats", timestamp=os.time() }) - local result = fs.read_file("/proc/net/dev") + local result = fs.read_file("/proc/net/dev") or "" -- parse the result local i=0 for line in string.gmatch(result, "[^\n]+\n?") do |