applications/luci-statistics: make host selectable if collectd-mod-network server...
[project/luci.git] / applications / luci-statistics / luasrc / statistics / rrdtool.lua
index 871e055..844c157 100644 (file)
@@ -34,11 +34,6 @@ function Graph.__init__( self, timespan, opts )
        local uci = luci.model.uci.cursor()
        local sections = uci:get_all( "luci_statistics" )
 
-       -- helper classes
-       self.colors = luci.statistics.rrdtool.colors.Instance()
-       self.tree   = luci.statistics.datatree.Instance()
-       self.i18n   = luci.statistics.i18n.Instance( self )
-
        -- options
        opts.timespan  = timespan       or sections.rrdtool.default_timespan or 900
        opts.rrasingle = opts.rrasingle or ( sections.collectd_rrdtool.RRASingle == "1" )
@@ -49,6 +44,11 @@ function Graph.__init__( self, timespan, opts )
        opts.rrdpath   = opts.rrdpath:gsub("/$","")
        opts.imgpath   = opts.imgpath:gsub("/$","")
 
+       -- helper classes
+       self.colors = luci.statistics.rrdtool.colors.Instance()
+       self.tree   = luci.statistics.datatree.Instance(opts.host)
+       self.i18n   = luci.statistics.i18n.Instance( self )
+
        -- rrdtool default args
        self.args = {
                "-a", "PNG",
@@ -513,20 +513,20 @@ function Graph.render( self, plugin, plugin_instance, is_index )
 
                -- get diagram definitions
                for i, opts in ipairs( self:_forcelol( def.rrdargs( self, plugin, plugin_instance, nil, is_index ) ) ) do
+                       if not is_index or not opts.detail then
+                               _images[i] = { }
 
-                       _images[i] = { }
-
-                       -- get diagram definition instances
-                       local diagrams = self:_generic( opts, plugin, plugin_instance, nil, i )
+                               -- get diagram definition instances
+                               local diagrams = self:_generic( opts, plugin, plugin_instance, nil, i )
 
-                       -- render all diagrams
-                       for j, def in ipairs( diagrams ) do
+                               -- render all diagrams
+                               for j, def in ipairs( diagrams ) do
+                                       -- remember image
+                                       _images[i][j] = def[1]
 
-                               -- remember image
-                               _images[i][j] = def[1]
-
-                               -- exec
-                               self:_rrdtool( def )
+                                       -- exec
+                                       self:_rrdtool( def )
+                               end
                        end
                end