[Omaha.pm] Re: rrdtool rulez

Jay Hannah jay at jays.net
Fri Jan 14 15:21:03 PST 2005


On Jan 14, 2005, at 4:17 PM, Mike Schilli wrote:
> On Fri, 14 Jan 2005, Jay Hannah wrote:
>> Using a Perl library to talk to RRD makes things even quicker to set 
>> up:
>>     http://search.cpan.org/~mschilli/RRDTool-OO-0.11/lib/RRDTool/OO.pm
>>     (Thanks Mike!!)
>
> You're very welcome, glad you like it :).

:)

Are you the helpdesk too? -grin-

If you have a minute maybe you could help. If not don't worry about it.

Below is a snippet I'm using to create 4 graphs. Questions:

1) You'll notice I used color 'FFFFFF' on the first 4 datasets. That's 
because I didn't really want to graph those (for these graphs), I just 
wanted to get them defined so I could calculate the 5th dataset. In 
pure rdtool I could have used DEF to define but not graph those, but 
under RRDToool::OO it looks like I'm always automatically CDEF'ing so I 
always end up graphing. Am I missing something? Is there some way I 
could have used 'cnt' in the final 'cdef' w/o graphing it?

2) You'll notice my super-ugly @args hackery at the bottom to get my 
historical graphs done. Anything obvious I should be doing instead?

3) Is RPN a total pain or is it just me? -grin-

Thanks again!

j



    my $rrd = RRDTool::OO->new(
              file => "$dir/rrds/USW-cnt.rrd" );

    my $image = "$dir/pngs/capacity_level1.png";
    my @args = (
       image          => $image,
       #lazy           => undef,
       vertical_label => 'Capacity',
       start          => time() - (60*60*16),
       end            => time(),
       width          => 960,
       draw           => {
           type   => "area",
           file   => "$dir/rrds/USW-cnt.rrd",
           color  => 'FFFFFF',
           legend => 'USW-cnt',
           name   => 'cnt',
       },
       draw           => {
           type   => "stack",
           file   => "$dir/rrds/perseus1.rrd",
           color  => 'FFFFFF',
           legend => 'perseus1',
           name   => 'perseus1',
       },
       draw           => {
           type   => "stack",
           file   => "$dir/rrds/perseus2.rrd",
           color  => 'FFFFFF',
           legend => 'perseus2',
           name   => 'perseus2',
       },
       draw           => {
           type   => "area",
           file   => "$dir/rrds/USW-drops.rrd",
           color  => 'FFFFFF',
           legend => 'USW-drops',
           thickness => 1,
           name   => 'drops',
       },
       draw           => {
           type   => "line",
           file   => "$dir/rrds/USW-drops.rrd",
           color  => 'FF00FF',
           legend => 'capacity',
           cdef   => 
"drops,0,GT,perseus1,perseus2,+,cnt,+,drops,-,NAN,IF",
           thickness => 1,
       },
    );
    $rrd->graph(@args);
    $args[1] = "$dir/pngs/capacity_level2.png";
    $args[5] = time() - (60*30*960);
    $args[11]{cfunc} = 'AVERAGE';
    $args[13]{cfunc} = 'AVERAGE';
    $args[15]{cfunc} = 'AVERAGE';
    $args[17]{cfunc} = 'AVERAGE';
    $rrd->graph(@args);
    $args[1] = "$dir/pngs/capacity_level3.png";
    $args[5] = time() - (60*60*2*960);
    $rrd->graph(@args);
    $args[1] = "$dir/pngs/capacity_level4.png";
    $args[5] = time() - (60*60*24*960);
    $rrd->graph(@args);




More information about the Omaha-pm mailing list