[rrd-users] Having trouble getting error msg from RRDp perl module; hangs indefinitely

Jason jason_jks at yahoo.com
Wed May 23 19:32:47 CEST 2007


Hi all,

I'm having trouble with error handling using the RRDp module.  I need to be able to handle the error if the RRDp::cmd command fails for any reason, but I cannot, for the life of me, figure out how to get it out properly.

I've just been doing speed tests using RRDp vs. using /usr/bin/rrdtool and RRDp is so much faster for multiple requests.  The only problem is, when the RRDp::cmd fails, the RRDp::read will just hang, forever.  If I unset RRDp::error_mode, then the RRDp pipe will just croak and my pipe is closed.  I guess if the pipe closes, then I could grab the error message from STDOUT and re-open the pipe, however it would just be nice to able to use RRDp::read to get the error message and not have to worry about it closing on me.

I've attached the test code that I've been working on.  If the command is successful, everything is fine, however if I the command fails, it will hang forever.  To simulate a failure, I just removed the write permissions on the rrd directory.  Same happens if I send RRDp::cmd bogus arguments.

Can anyone shed some light on this?

RRDTool version 1.2.19
Perl version 5.8.8
Debian Linux 2.6.17

Thanks very much,
Jason Schoonover

Code:
-----------------------------------------------------

use strict;
use RRDp;

my $rrdtool_bin = '/usr/bin/rrdtool';

my $pid = RRDp::start $rrdtool_bin;
$RRDp::error_mode = 'catch';

my $dir = './t';
system ("rm -fr $dir");
mkdir $dir;

my $now = time; 

foreach my $num (0..10) {

        my $rrd = $dir . '/' . $num . '.rrd';

        RRDp::cmd "create --start $now $rrd DS:speed:GAUGE:86400:0:U DS:in:COUNTER:86400:0:U DS:out:COUNTER:86400:0:U RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";

        my $answer = RRDp::read;
        print $RRDp::error if $RRDp::error;
        my ($usertime,$systemtime,$realtime) =  ($RRDp::user,$RRDp::sys,$RRDp::real);

        print "$rrd: $realtime\n";
}

my $end_res = RRDp::end;

print "end_res is $end_res\n";






More information about the rrd-users mailing list