[rrd-users] Problem with timestamp from RRDs::last

Karl Fischer rrd-users at ficos.de
Thu Jun 16 16:18:32 CEST 2011


Am 16.06.2011 13:30, schrieb faema:
> Hi,
> have been using perl and rrdtool on Solaris sparc for years, but when
> running the same script on Solaris x86, I get problems with RRD::last, the
> time returned is false.
> The testscript returns: lastupdate: 577716223951862640
> while rrdtool returns the correct time:
> /usr/local/rrdtool-1.0.49/bin/rrdtool last ROUTER1.rrd
> 1168210800
> 
> my testscript:
> #!/usr/bin/perl -w
> #
> use strict;
> use lib qw( /usr/local/rrdtool-1.0.49/lib/perl ../lib/perl );
> use RRDs;
> 
> my $rrd = "ROUTER1.rrd";
> my $lastupdate = 0;
> $lastupdate = RRDs::last $rrd;
> if (my $Error = RRDs::error) {
>     print STDOUT "RRD::last, ERROR: $Error\n";
> }
> 
> printf ("lastupdate: %d \n", $lastupdate );
> 
> Perl used is the standard 32-bit, on Solaris 10. 
> #: /usr/bin/perl -v
> This is perl, v5.8.4 built for i86pc-solaris-64int

Hi Mats,

using a 32-bit perl on a 64bit system seems to be unfortunate somehow.
However, interestingly your perl script happily returns a 64bit number.

If you force that to 32bit, you get what you'd expect:

# perl -e 'printf "%d\n", 577716223951862640 & 0xffffffff'
1168210800

There may be a problem in the perl binding on Solaris, but since
UNIX timestamps always are 32bit (valid until 2038) it seems to
be a safe workaround to force it down to 32bit for now:

$lastupdate = RRDs::last $rrd;
$lastupdate &= 0xffffffff;

hth

- Karl






More information about the rrd-users mailing list