[rrd-users] A script to help write RRAs
Noah Leaman
noah at mac.com
Fri Mar 5 09:02:12 MET 2004
In an attempt to think a little less, I wrote a tiny perl script to
help me define my RRAs. Can you all just confirm that my calculations
are correct? I am still kinda a newbie and sometimes get confused with
the numbers but I want to be sure I am constructing my RRDs the way I
want them since it sucks to have to re-create the RRD and lose data.
The script (I call it rra_calc.pl) takes in 3 arguments. The --step,
number of steps, and number of rows. The output looks like this:
$ ./rra_calc.pl 300 1 288
Data Retention Timeframe: 0y 1d 0s 0s 0s (86400 secs)
Sample Resolution: 0y 0d 0s 5s 0s (300 secs)
This one uses a 10 minute (600 seconds) --step (or PDP) setting:
$ ./rra_calc.pl 600 144 1850
Data Retention Timeframe: 5y 25d 0s 0s 0s (159840000 secs)
Sample Resolution: 0y 1d 0s 0s 0s (86400 secs)
--
Noah
Here is the code:
#!/usr/bin/perl -w
use strict;
if(!defined($ARGV[0])) {
print "USAGE: $0 <step_size> <no_of_steps> <no_of_rows>\n";
exit(0);
}
my $step_size = $ARGV[0]; # --step (amount of time that defines the
primary data points)
my $no_of_steps = $ARGV[1]; # steps (number of steps used to define a
single archive sample)
my $rows = $ARGV[2]; # rows (number of archive samples to store)
my $sample_size_secs = $step_size * $no_of_steps;
my $sample_size = convert_to_time($sample_size_secs);
my $retention_secs = $sample_size_secs * $rows;
my $retention = convert_to_time($retention_secs);
print "Data Retention Timeframe: $retention ($retention_secs secs)\n";
print "Sample Resolution: $sample_size ($sample_size_secs
secs)\n\n";
sub convert_to_time {
my $total_seconds = shift;
my $years = sprintf("%d", $total_seconds / 31536000);
my $days = sprintf("%d", ($total_seconds - ($years * 31536000)) /
86400);
my $hours = sprintf("%d", ($total_seconds - ($years * 31536000) -
($days * 86400)) / 3600);
my $minutes = sprintf("%d", ($total_seconds - ($years * 31536000) -
($days * 86400) - ($hours * 3600)) / 60);
my $seconds = sprintf("%d", $total_seconds - ($years * 31536000) -
($days * 86400) - ($hours * 3600) - ($minutes * 60));
my $formated_time = sprintf("%3dy %3dd %3ds %3ds %3ds", $years, $days,
$hours, $minutes, $seconds);
return($formated_time);
}
--
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