Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

help with rrdtool::oo and dinamic draw

by guacamayo (Acolyte)
on Apr 21, 2011 at 12:31 UTC ( #900592=perlquestion: print w/ replies, xml ) Need Help??
guacamayo has asked for the wisdom of the Perl Monks concerning the following question:

Hello! I need some help ... :-)
foreach my $row (@sensor_h) { push(@draw, {draw => { file => "../data/$row", legend => "Source 1", + thickness => 2, color => '00FF00' }}); }
... with Data::Dumper i see ...
$VAR1 = { 'draw' => { 'thickness' => 2, 'color' => '00FF00', 'legend' => 'Source 1', 'file' => '../data/4C0008008E4F7E10' } }; $VAR2 = { 'draw' => { 'thickness' => 2, 'color' => '00FF00', 'legend' => 'Source 1', 'file' => '../data/DE0008008E479910' } }; $VAR3 = { 'draw' => { 'thickness' => 2, 'color' => '00FF00', 'legend' => 'Source 1', 'file' => '../data/AB0008008E533410' } };
and now my problem / ask ...
$rrd->graph( #image => '-', image => "../images/" . $sensor . ".png", vertical_label => 'Sensors', width => $width, height => $height, start => time() - $period, draw => { file => "../data/sensor1.rrd", legend => "Source + 1", thickness => 2, color => '00FF00' }, @draw );
also, i need dinamic numbers of draw ( see on top). the error ...
'Odd number of elements in hash assignment at /usr/lib/perl5/site_perl +/5.8.8/RRDTool/OO.pm line 178. Illegal parameter 'HASH(0xf6cf030)' in graph() at graph.cgi line ...
How can i make then thats work ? Thanks a lot

Comment on help with rrdtool::oo and dinamic draw
Select or Download Code
Re: help with rrdtool::oo and dinamic draw
by SimonClinch (Chaplain) on Apr 21, 2011 at 12:38 UTC
    it looks like the graph method, (though not shown) is converting the calling parameters into a hash. And that's what you start off expecting when suddenly you put @draw at the end of the call parameters, which has three elements (forcing total odd). You need to exchange @draw for something like some_key => \@draw I would imagine.

    One world, one people

      Hi! Thanks, a step further :-) and now ..
      foreach my $row (@sensor_h) { push(@draw, { file => "../data/$row.rrd", legend => "Source 1", thic +kness => 2, color => '00FF00' }); }
      $rrd->graph( #image => '-', image => "../images/" . $sensor . ".png", vertical_label => 'Sensors', width => $width, height => $height, start => time() - $period, draw => { file => "../data/sensor1.rrd", legend => "Source + 1", thickness => 2, color => '00FF00' }, draw => $draw[0], draw => $draw[1], ... and so on ... );
      yes, so works but i need to pass or join a hash with more draw occurrences thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://900592]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2015-07-07 03:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls