From ed71ae19d09a7776f01427ef5032db140f5977f7 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Wed, 8 Jul 2009 11:55:02 +0000 Subject: Fetching graph-settings from external configfiles. Rebuilding the view to be able to make the configfiles simple to use. --- rrdtool-model.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'rrdtool-model.lua') 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 -- cgit v1.2.3