summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rrdtool-listgraphs-html.lsp4
-rw-r--r--rrdtool-listrrd-html.lsp2
-rw-r--r--rrdtool-model.lua20
3 files changed, 22 insertions, 4 deletions
diff --git a/rrdtool-listgraphs-html.lsp b/rrdtool-listgraphs-html.lsp
index 9d41cfc..14e97e7 100644
--- a/rrdtool-listgraphs-html.lsp
+++ b/rrdtool-listgraphs-html.lsp
@@ -16,8 +16,8 @@ io.write("</span>")
<%
for grp,v in pairs(data) do
%>
-<H2><% if (#v.label > 0) then io.write(tostring(v.label)) else io.write(grp) end %></H2>
- <% for k,graph in pairs(v.value) do %>
+<H2><% io.write(grp) %></H2>
+ <% for k,graph in pairs(v) do %>
<DL><DT>
<A HREF="viewgraph?group=<%= grp %>&id=<%= k %>"><IMG SRC='<%= icon %>' width='16' height='16'> <% io.write(graph.label or "Unknown") %></A></DT>
<DD><% io.write(graph.descr or "") %></DD>
diff --git a/rrdtool-listrrd-html.lsp b/rrdtool-listrrd-html.lsp
index 8eb80c2..6883258 100644
--- a/rrdtool-listrrd-html.lsp
+++ b/rrdtool-listrrd-html.lsp
@@ -47,7 +47,7 @@ function javascript_confirm_demo(formID,filename) {
</TD>
<TD style="padding-right:20px;white-space:nowrap;text-align:right;"><%= html.html_escape(file.value.filesize.value) %></TD>
<TD style="padding-right:20px;white-space:nowrap;"><%= html.html_escape(file.value.mtime.value) %></TD>
- <TD style="white-space:nowrap;" width="90%"><%= html.html_escape(string.gsub(file.value.filename.value, "^.*/", "")) %></TD>
+ <TD style="white-space:nowrap;" width="90%"><%= html.html_escape(file.value.filename.value) %></TD>
</TR>
<% end %>
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