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

This is a discussion on [rrd-users] Re: Q about copying an existing rrd database and zeroing out the data within the RRD Users forums, part of the Networking and Network Related category; Bill, What you want to do is parse the $key portion of the hash, and if it's something that ...


Go Back   Usenet Forums > Networking and Network Related > RRD Users

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-17-2005
Daniel Magnuszewski
 
Posts: n/a
Default [rrd-users] Re: Q about copying an existing rrd database and zeroing out the data

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@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@list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request@list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:40 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0