[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Re: rrdtool rulez




From m@perlmeister.com Sat Jan 15 20:28:07 2005
From: Mike Schilli <m@perlmeister.com>
To: Jay Hannah <jay@jays.net>
Cc: Mike Schilli <m@perlmeister.com>,
     Omaha Perl Mongers Mongers <omaha-pm@pm.org>
Subject: Re: rrdtool rulez
Date: Sat, 15 Jan 2005 20:15:46 -0800 (PST)

On Fri, 14 Jan 2005, Jay Hannah wrote:

Are you the helpdesk too? -grin-

Ha! :) Sure.

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?

RRDTool:OO 0.11 introduced "type => 'hidden'" for graphs which you don't want
to draw.

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?

Hmm, relying on array indices for the different draws could bite you
at some point :). How about encapsulating the call to ->draw() in
a function like

    sub drawgraph {
        my($rrd, %options) = @_;

        $options{start}    ||= time() - (60*60*16);
        $options{cfunc}    ||= 'MAX';

        $rrd->graph(
            image          => $image,
        vertical_label => 'Capacity',
        start          => $options{start},     ###### !!!!
        end            => time(),
        width          => 960,
        draw           => {
            type   => "area",
            file   => "$dir/rrds/USW-cnt.rrd",
            color  => 'FFFFFF',
            legend => 'USW-cnt',
            name   => 'cnt',
            cfunc  => $options{cfunc},         ###### !!!!
        },
        # ...
    }

which uses optional parameters and defaults to sensible defaults if
they're omitted?

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

It helps if you have spent considerable time programming HP-41CV's in the
80ies :). But of course, today it makes things unnecessarily complex.

When I wrote RRDTool::OO, I was very close to adding a 'normal'
arithmetic parser, transforming everything into RPN before handing it
over to RRDTool. Hey, maybe I'll take it on now :).

-- Mike

Mike Schilli
m@perlmeister.com