For..next loops within RRDs Perl module calls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

For..next loops within RRDs Perl module calls

m_elias
I'd like to create a graph creation subroutine that allows for a dynamic or variable number of DEF and CDEF. What I mean by dynamic is, that some graphs will have 6 DEFs, some will have 13, the perl script would set the number of cycles for the for..next loop which would be within the RRDs module call.

Any suggestions on how to do this? I have been unsuccessful in figuring it out myself. Or do I have to pass command line arguments instead of using the RRDs module?
Reply | Threaded
Open this post in threaded view
|

Re: For..next loops within RRDs Perl module calls

David Thornton
What I do in this case is write scripts that write scripts.

For example if I have a bunch of similar devices , but each device has
a different number of variables, I write a script that writes an
rrdcgi for each device.

Most recently is was brightmail spam bucket graphs.  I have 11 dcs
each with a different number of brightmail devices. For each
datacentre write an rrdcgi that aggregates whatever the number of
brightmail devices are in that datacentre.

It's not as elegant as say a single script that you use for all
datacentres , but it does get the job done.

On a related note has anyone played around with squeezing lots of
cdefs in one graph? My big datacentres segfault with complicated
graphs. So for example if I add 40 points together and plot the sum it
works, but if I stack all those points it falls over.

Do I need to break out gdb and strace or have I tell rrd "I'm going to
feed you a lot of data, be prepared"?

(A la jvm xmx xms?)

David

On 6/3/11, m_elias <[hidden email]> wrote:

> I'd like to create a graph creation subroutine that allows for a dynamic or
> variable number of DEF and CDEF. What I mean by dynamic is, that some graphs
> will have 6 DEFs, some will have 13, the perl script would set the number of
> cycles for the for..next loop which would be within the RRDs module call.
>
> Any suggestions on how to do this? I have been unsuccessful in figuring it
> out myself. Or do I have to pass command line arguments instead of using the
> RRDs module?
>
> --
> View this message in context:
> http://rrd-mailinglists.937164.n2.nabble.com/For-next-loops-within-RRDs-Perl-module-calls-tp6435876p6435876.html
> Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.
>
> _______________________________________________
> rrd-users mailing list
> [hidden email]
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>

--
Sent from my mobile device

_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: For..next loops within RRDs Perl module calls

Martin Rushworth
In reply to this post by m_elias
I think what you are looking for is something along these lines..

you can pass the data as an array to RRDs::graph, so instead of doing something like...

my ($avg,$xsize,$ysize) = RRDs::graph "-","--title", "Bits Graph","--height","300",,,,etc,,etc,;

you can do

my @array = ("-","--title", "Bits Graph","--height","300",,,etc,,,);

and then any combination of iteration or selection you like
        push(@array, $foo);

and then do...

my ($avg,$xsize,$ysize) = RRDs::graph @array;

does that make sense?

On 3 Jun 2011, at 17:12, m_elias wrote:

> I'd like to create a graph creation subroutine that allows for a dynamic or
> variable number of DEF and CDEF. What I mean by dynamic is, that some graphs
> will have 6 DEFs, some will have 13, the perl script would set the number of
> cycles for the for..next loop which would be within the RRDs module call.
>
> Any suggestions on how to do this? I have been unsuccessful in figuring it
> out myself. Or do I have to pass command line arguments instead of using the
> RRDs module?
>
> --
> View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/For-next-loops-within-RRDs-Perl-module-calls-tp6435876p6435876.html
> Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.
>
> _______________________________________________
> rrd-users mailing list
> [hidden email]
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users


_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
Reply | Threaded
Open this post in threaded view
|

Re: For..next loops within RRDs Perl module calls

m_elias
Thanks for the replies, I am now till the stage in my project where it is time to write this code. I'm pretty sure I can make it work as Mr Thornton suggested, but I'm curious about Mr Rushworth's suggestion. Martin, can you elaborate a bit more on your array passing technique? I'm not clear as to what is all happening. Below is a sample of how I've been generating graphs with the RRDs module. It shows only a few DEFs but my goal is to graph as many temp sensors as each bin has rrd files (6-13) with one graph per bin. $_[0] is the bin number and $_[1] the time frame.

        RRDs::graph("$img/bin$_[0]-temps-$_[1].png",
                "-s", "-$_[1]",
                "-t", "$_[0] Waterlevels: $_[1]",
                "-h", "$gheight", "-w", "$gwidth",
                "-a", "PNG",
                "-v", "Temp C",

                "DEF:sensor1=$rrd/bin$_[0]-1.temps.rrd:Temp:AVERAGE",
                "DEF:sensor2=$rrd/bin$_[0]-2.temps.rrd:Temp:AVERAGE",
                .
                .
                .
                "DEF:sensor10=$rrd/bin$_[0]-10.temps.rrd:Temp:AVERAGE",

                "CDEF:nan=sensor1,UN,INF,UNKN,IF",
                "AREA:nan#FF000070",
               
                "LINE1:sensor1#32CD32:Sensor 1",
                "LINE2:sensor2#4169E1:Sensor 2",
                .
                .
                .
                "LINE10:sensor10#4169E1:Sensor 10");

So I just push all the bits into an array, each section in quotes being an element?

push (@array, "-s");
push (@array, "-$_[1]");
push (@array, "-t");
etc

Then I'm confused by the "my ($avg,$xsize,$ysize) =" bit in front of "RRDs::graph @array;" .

Thanks, again.
Reply | Threaded
Open this post in threaded view
|

Re: For..next loops within RRDs Perl module calls

m_elias
I think I've got it figured out, thanks guys.