Changeset 7980
- Timestamp:
- 11/28/11 04:24:37 (19 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
luci/trunk/applications/luci-statistics/luasrc/statistics/rrdtool.lua
r5104 r7980 18 18 require("luci.statistics.datatree") 19 19 require("luci.statistics.rrdtool.colors") 20 require("luci.statistics.rrdtool.definitions")21 20 require("luci.statistics.i18n") 22 21 require("luci.model.uci") … … 38 37 -- helper classes 39 38 self.colors = luci.statistics.rrdtool.colors.Instance() 40 self.defs = luci.statistics.rrdtool.definitions.Instance()41 39 self.tree = luci.statistics.datatree.Instance() 42 40 self.i18n = luci.statistics.i18n.Instance( self ) … … 272 270 273 271 -- create line1 statement 274 _tif( _args, "LINE1:%s_%s#%s:%s", source.sname, var, line_color, legend ) 272 _tif( _args, "LINE%d:%s_%s#%s:%s", 273 source.noarea and 2 or 1, 274 source.sname, var, line_color, legend ) 275 275 end 276 276 … … 375 375 local dsname = dtype .. "_" .. dinst:gsub("[^%w]","_") .. "_" .. dsource 376 376 local altname = dtype .. "__" .. dsource 377 378 --assert(dtype ~= "ping", dsname .. " or " .. altname) 377 379 378 380 -- find datasource options … … 400 402 overlay = dopts.overlay or false, 401 403 noarea = dopts.noarea or false, 404 title = dopts.title or nil, 402 405 ds = dsource, 403 406 type = dtype, … … 445 448 -- store title and vlabel 446 449 _ti( _args, "-t" ) 447 _ti( _args, opts.title or self.i18n:title( plugin, plugin_instance, _sources[1].type, instance ) )450 _ti( _args, self.i18n:title( plugin, plugin_instance, _sources[1].type, instance, opts.title ) ) 448 451 _ti( _args, "-v" ) 449 _ti( _args, opts.vlabel or self.i18n:label( plugin, plugin_instance, _sources[1].type, instance) )452 _ti( _args, self.i18n:label( plugin, plugin_instance, _sources[1].type, instance, opts.vlabel ) ) 450 453 451 454 -- store additional rrd options … … 495 498 end 496 499 497 function Graph.render( self, plugin, plugin_instance )500 function Graph.render( self, plugin, plugin_instance, is_index ) 498 501 499 502 dtype_instances = dtype_instances or { "" } … … 510 513 511 514 -- get diagram definitions 512 for i, opts in ipairs( self:_forcelol( def.rrdargs( self, plugin, plugin_instance ) ) ) do515 for i, opts in ipairs( self:_forcelol( def.rrdargs( self, plugin, plugin_instance, nil, is_index ) ) ) do 513 516 514 517 _images[i] = { } … … 534 537 end 535 538 end 536 else537 538 -- no graph handler, iterate over data types539 for i, dtype in ipairs( self.tree:data_types( plugin, plugin_instance ) ) do540 541 -- check for data type handler542 local dtype_def = plugin_def .. "." .. dtype543 local stat, def = pcall( require, dtype_def )544 545 if stat and def and type(def.rrdargs) == "function" then546 547 -- temporary image matrix548 local _images = { }549 550 -- get diagram definitions551 for i, opts in ipairs( self:_forcelol( def.rrdargs( self, plugin, plugin_instance, dtype ) ) ) do552 553 _images[i] = { }554 555 -- get diagram definition instances556 local diagrams = self:_generic( opts, plugin, plugin_instance, dtype, i )557 558 -- render all diagrams559 for j, def in ipairs( diagrams ) do560 561 -- remember image562 _images[i][j] = def[1]563 564 -- exec565 self:_rrdtool( def )566 end567 end568 569 -- remember images - XXX: fixme (will cause probs with asymmetric data)570 for y = 1, #_images[1] do571 for x = 1, #_images do572 table.insert( pngs, _images[x][y] )573 end574 end575 else576 577 -- no data type handler, fall back to builtin definition578 if type(self.defs.definitions[dtype]) == "table" then579 580 -- iterate over data type instances581 for i, inst in ipairs( self.tree:data_instances( plugin, plugin_instance, dtype ) ) do582 583 local title = self.i18n:title( plugin, plugin_instance, dtype, inst )584 local label = self.i18n:label( plugin, plugin_instance, dtype, inst )585 local png = self:mkpngpath( plugin, plugin_instance, dtype, inst )586 local rrd = self:mkrrdpath( plugin, plugin_instance, dtype, inst )587 local args = { png, "-t", title, "-v", label }588 589 for i, o in ipairs(self.defs.definitions[dtype]) do590 -- XXX: this is a somewhat ugly hack to exclude min/max RRAs when rrasingle is on591 if not ( self.opts.rrasingle and ( o:match("_min") or o:match("_max") ) ) then592 table.insert( args, o )593 end594 end595 596 -- remember image597 table.insert( pngs, png )598 599 -- exec600 self:_rrdtool( args, rrd )601 end602 end603 end604 end605 539 end 606 540
