Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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) ; } ;

Ciao!
--bronto


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

In reply to How to create a COMPUTE data source in RRDTool::OO by bronto
in thread RRDTool::OO not able to create a COMPUTE data source? by bronto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (3)
    As of 2020-10-24 17:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favourite web site is:












      Results (246 votes). Check out past polls.

      Notices?