Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

How to create a COMPUTE data source in RRDTool::OO

by bronto (Priest)
on Nov 22, 2010 at 14:59 UTC ( #872980=note: print w/replies, xml ) Need Help??

in reply to RRDTool::OO not able to create a COMPUTE data source?

OK, I found out that there is not a way to create a COMPUTE resource out of the box in RRDTool::OO, but it is possible to workaround this lack of functionality by using the dry run mode. Here is how.

First, you need to create an RRDTool::OO object in dry run mode. Then you prepare all the "standard" data sources in the usual way, and call create. It won't actually execute the call, but now you can retrieve a reference to the function that it would have called, along with a reference to the function arguments. You can now fiddle with the arguments and call the function when you are ready.

This is how I did it:

# Creation of a COMPUTE data source is not contemplated in the # documentation, nor it is in the code. That's why we use an # object in dry-run mode: we'll get a reference to the function # and arguments that were about to be called, and add our # resource. Finally, we run the call. # Pretty bad it didn't have the function already... my $dsdef = q{DS:aggregate:COMPUTE:}. join(",",@dsources).",ADDNAN"x$#dsources ; $rrdbuilder->create(@rrd_parms) ; # Get references to the RRD function and arguments # Push the COMPUTE data source in it # Run the create command, see what happens my ($subref,$args) = $rrdbuilder->get_exec_env(); push @$args,$dsdef ; eval { $subref->(@$args) ; } ;


In theory, there is no difference between theory and practice. In practice, there is.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://872980]
[Discipulus]: chickenman do you know which kind of configuration file do you have? it is some standard?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-02-20 08:06 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (268 votes). Check out past polls.