[rrd-users] Anyone Using LARRD?

Larry Sabados (IT) LSABADOS at bordersgroupinc.com
Thu Nov 16 15:43:58 MET 2006


Hello-
I'm totally clueless when it comes to making new graphs using LARRD.  I have plagiarized RRD gathering scripts when I need to grab one data metric from a Big Brother status message but how do I do about collecting 2 from the same status?  Any help would be ...helpful.  I have dug all over the RRDTOOL docs and it's not coming together.  I have included one of the perl scripts which collects a cpu utilization metric from a Big Brother status message.  Can someone tell me how I could modify this to collect more than the one  metric if more than one was in the BB status message?  Thanks.

#!/usr/opt/perl5/bin/perl
#
# $Id: template-larrd.pl,v 1.6 2003/03/18 16:48:12 cncook Exp $
#
# template-larrd.pl: larrd module template
#
# Scott Walters Copyright 1999
# scott at PacketPushers.com 
#  
# Christian Pearce
# pearcec at PacketPushers.com
#
# Do whatever you want with it
# just don't sell it and make money off of it and not cut me in ;)
# I take no liability for it, use at your own risks

# this is for after install
use lib $ENV{'RRDPM'};
use RRDs;

##################################
# SETUP
##################################

# 1. Define the extention for the metric

$ds = "cpu-util";
#@ds = ("DS:cpuutil:GAUGE:600:0:U"
@ds = ("DS:cpuutil:GAUGE:1200:0:U");
#@ds = ("DS:cpuutil:COUNTER:1400:0:U"
#);

##################################
# Start of script
##################################

if( not $ENV{'BBHOME'} ) {
        print "$0: BBHOME is not set\n";
        exit(1);
}

if( not -d $ENV{'BBHOME'} ) {
        print "$0: BBHOME is invalid\n";
        exit(1);
}

if( not -d $ENV{'BBRRDS'} ) {
        print "$0: BBRRDS is not set\n";
        exit(1);
}

##
# real work begins here
##

# Glob the bind logs and data
my %h_fn;

# Perl Cookbook Recipe 9.5
opendir(DIR, "$ENV{'BBLOGS'}") or die "$0: $!";
while ( defined($log = readdir(DIR))) {
        next unless $log =~ /\.$ds$/io;
        my $host = $log;
        $host =~ s/\.$ds//;
        $host =~ s/\,/\./g;

        $h_fn{$host}="$ENV{'BBLOGS'}/$log";
}
closedir(DIR);

opendir(DIR, "$ENV{'BBVAR'}/data") or die "$0: $!";
while ( defined($log = readdir(DIR))) {
        next unless $log =~ /\.$ds$/io;
        my $host = $log;
        $host =~ s/\.$ds//;
        $host =~ s/\,/\./g;

        $h_fn{$host}="$ENV{'BBVAR'}/data/$log";
}
closedir(DIR);

while ( ($host,$log) = each %h_fn ) {


        print "$0 : DEBUG log=$log\n" if ($ENV{'DEBUG'});

        open(LOG,"$log");
        
        $temp = <LOG> if $log =~ /$ENV{'BBLOGS'}/io;

        # If you data source is supplying a BBOSTYPE with the status log

# 2. Grab the data from the log how ever you need
$cpuutil=<LOG>;
@CPUUTIL = split("<b>", $cpuutil);
$cpuutil = @CPUUTIL[1];
@CPUUTIL = split("%", $cpuutil);
$cpuutil = @CPUUTIL[0];
chomp $cpuutil;
$cpuutil =~ s/(^ *)||( *$)//g;
`echo "test" > cputestingout`;




# 3. grab the timpstamp for rrd. 

        # Sometimes you get it from stat sometimes you get it from the log
        ($ctime) = (stat($log))[10];
        print "$0 : DEBUG ctime = $ctime\n" if ($ENV{'DEBUG'});

# 4. create the rrd filename

        $RRD="$ENV{'BBRRDS'}/$host.cpu_util.rrd";

        print "$0 : RRD=$RRD\n" if ($ENV{'DEBUG'});

        # see if the RRD is around, if not make it      
        if ( not -f $RRD ) {
                
                # keeping this much disk data seems overkill
                # but thought 'standardizing' RRD's would be worth it
                # 30 seconds....
                @rras = split " ",$ENV{'RRAS'};
                RRDs::create($RRD, at ds, at rras);
                $ERR=RRDs::error;
                if($ERR) {
                        print "$0: ERROR creating $RRD: $ERR\n" if ($ENV{'ERROR'});
                        next; #does this work? yup!
                }
                $ctime="N";
                print "$0: STATUS did not find $RRD, created.\n" if ($ENV{'STATUS'});
        }

# 5. Put your data from step 2 to the rrd

        # now update the RRD
        RRDs::update("$RRD","$ctime:$cpuutil");
        $ERR=RRDs::error;
        if($ERR) {
                print "$0: WARN updating $RRD: $ERR\n" if ($ENV{'WARN'})
;
        }
        unlink $log if $ENV{'LARRDCOMM'} =~ /DATA/i;

}       
##############################################
# end of script
##############################################

Larry Sabados
Borders Group Inc
IT-Product Administration
W/Ph(734) 477-2829


--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive     http://lists.ee.ethz.ch/rrd-users
WebAdmin    http://lists.ee.ethz.ch/lsg2.cgi



More information about the rrd-users mailing list