[rrd-users] Re: Q about copying an existing rrd database and zeroing out the data

Daniel Magnuszewski dmagnuszewski at yahoo.com
Thu Feb 17 08:28:52 MET 2005


Bill,

What you want to do is parse the $key portion of the hash, and if it's
something that you need to run the create command, then push the value of the
$key onto an array. From doing that, you can create an array of all the info
you need. 

For example:

#!/usr/bin/perl -w
use strict;
use RRDs;

my $newRRD  = "new.rrd";
my $oldRRD   = "old.rrd";
my $hash       = RRDs::info "$oldRRD";
my @newOptions;

foreach my $key (keys %$hash)
{
   if ($key =~ /step/)
   {
                # Push step value onto array
                push @newOptions, $$hash{$key};
   }
   elsif ($key =~ /ds\[(.+)\]\.type/)
   {
                # Push ds name onto array
                push @newOptions, $1;

                # Push ds type onto array
                push @newOptions, $$hash{$key};
   }
}

This should be a good start to what you're looking for. I'd say to just
continue with the if-else loop and parse out the rest of what you need, then
use it to run create.

I hope this helps!

-Dan
 

--- Bill Benedetto <bbenedetto at goodyear.com> wrote:

> Sorry but this just isn't crystal clear to me.
> 
> If I call RRDs::info, I get a hash that looks like this:
>   ds[Ping].last_ds = UNKN
>   ds[Ping].min = 0
>   ds[Ping].minimal_heartbeat = 900
>   ds[Ping].type = GAUGE
>   ds[Ping].unknown_sec = 0
>   ds[Ping].value = 0.04444
>   filename = /usr/local/nagios/rrd/tpcmweb-PING.rrd
>   last_update = 1108591004
>   rra[0].cdp_prep[0].unknown_datapoints = 0
>   rra[0].cf = AVERAGE
>   rra[0].pdp_per_row = 1
>   rra[0].rows = 50400
>   rra[0].xff = 0.5
>   rra[1].cdp_prep[0].unknown_datapoints = 0
>   rra[1].cdp_prep[0].value = 0.0299737333333333
>   rra[1].cf = AVERAGE
>   rra[1].pdp_per_row = 60
>   rra[1].rows = 43800
>   rra[1].xff = 0.5
>   rrd_version = 0001
>   step = 60
> 
> This, of course, is in a hash that I retrieved like this:
>   my $hash = RRDs::info $oldrrd;
> 
> But but I don't see how to get from that $hash to what I think I
> need for RRDs::create - namely an array of something like this
> "DS:NAME_HERE:GAUGE:600:0:U" (for example) and an array something
> like this: "RRA:AVERAGE:0.5:1:576 RRA:AVERAGE:0.5:6:576
> RRA:AVERAGE:0.5:24:576 RRA:AVERAGE:0.5:288:576" (for another
> example).
>
> Is there some easy way to get from the RRDs::info hash to what I
> need for RRDs::create?



	
		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - You care about security. So do we. 
http://promotions.yahoo.com/new_mail

--
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://www.ee.ethz.ch/~slist/rrd-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-users mailing list