diff options
author | Mika Havela <mika.havela@gmail.com> | 2009-07-08 11:55:02 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2009-07-08 11:55:02 +0000 |
commit | ed71ae19d09a7776f01427ef5032db140f5977f7 (patch) | |
tree | 11f787eb2dbbd8fb69bbe1b1b154934a96b51754 /rrdtool-model.lua | |
parent | 160b99981384e4225e84f98fd4f51d3ce3304ced (diff) | |
download | acf-rrdtool-ed71ae19d09a7776f01427ef5032db140f5977f7.tar.bz2 acf-rrdtool-ed71ae19d09a7776f01427ef5032db140f5977f7.tar.xz |
Fetching graph-settings from external configfiles.
Rebuilding the view to be able to make the configfiles simple to use.
Diffstat (limited to 'rrdtool-model.lua')
-rw-r--r-- | rrdtool-model.lua | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/rrdtool-model.lua b/rrdtool-model.lua index e0143ee..2b9344a 100644 --- a/rrdtool-model.lua +++ b/rrdtool-model.lua @@ -10,6 +10,7 @@ require("validator") -- Set variables local configfile = "/etc/rrdtool/acf-rrdtool.conf" +local graphpath = "/etc/rrdtool" local databases = "/etc/rrdtool/databases" local processname = "rrdtool" local packagename = "rrdtool" @@ -194,8 +195,25 @@ end function list_graphs() local graphs = {} + local files = fs.find_files_as_array(".*graph", graphpath) - --TODO: Read config-files and create a table of it. + for k,v in pairs(files) do + local filecontent = {} + for kk,vv in pairs(fs.read_file_as_array(v)) do + vv = string.gsub(vv,"\"", "") + local delim = string.find(vv, "\=") + if delim then + filecontent[string.sub(vv,1,(delim-1))]=string.sub(vv,(delim+1),#vv) + end + end + + if not (filecontent.group) then + filecontent.group = "General" + end + graphs[filecontent.group] = graphs[filecontent.group] or {} + + table.insert(graphs[(filecontent.group)],filecontent) + end return graphs end |