[rrd-users] RRDs::fetch() returns strange time values

jensr mail at jens-rannacher.de
Thu Mar 20 09:11:14 CET 2008


Hi Darren,

I tried the script on an other server and what a wonder, everything works
fine. I think the two servers have different rrdtool versions installed..

I use the fetch() function like this:

my $end = time();
my $start = $end - 7200;

my ($start, $step, $columns, $data) = RRDs::fetch($file, "--start=$start",
"--end=$end", "AVERAGE") or die "Cannot fetch rrd ($RRDs::error)";

print "Start:       ", scalar localtime($start), " ($start)\n";
print "Step:       ($step)\n";
print "DS names:    ", join (", ", @$column_names)."\n";
print "Data points: ", $#$data + 1, "\n";

And  to convert the returned times into a unix timestamp like this..

# calculate unix time stamp from unkown timestamp
$start = $start % $step;
# calculate step from unkown timestamp
@parts = localtime($step);
$step = $parts[0]; #seconds
$step += $parts[1] * 60; #minutes
$step += ($parts[2] - 1) * 60 * 60; #hours
$step += ($parts[5] - 70) * 60 * 60 * 24 * 365; #years
$step += ($parts[7]) * 60 * 60 * 24; #days
$start += $step;

Kind Regards
Jens



-- 
View this message in context: http://www.nabble.com/RRDs%3A%3Afetch%28%29-returns-strange-time-values-tp16116334p16173997.html
Sent from the RRDTool - User mailing list archive at Nabble.com.



More information about the rrd-users mailing list