diff options
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 |