X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=bindings%2Fperl-piped%2FRRDp.pm;h=83ffb600740724daa88ff564d7ce1efe24ff045d;hb=2e6c98e893777e4abf7b05cb4ecf81dde088cdb8;hp=06444ece0b627a015564ec05fdd6c726694083f5;hpb=c0be57bdf5f3fef44227f2e0acf6a7a74c1a7620;p=rrdtool.git diff --git a/bindings/perl-piped/RRDp.pm b/bindings/perl-piped/RRDp.pm index 06444ec..83ffb60 100644 --- a/bindings/perl-piped/RRDp.pm +++ b/bindings/perl-piped/RRDp.pm @@ -16,7 +16,7 @@ $answer = B $status = B -B<$RRDp::user>, B<$RRDp::sys>, B<$RRDp::real> +B<$RRDp::user>, B<$RRDp::sys>, B<$RRDp::real>, B<$RRDp::error_mode>, B<$RRDp::error> =head1 DESCRIPTION @@ -69,6 +69,16 @@ The difference between user + system and real is the time spent waiting for things like the hard disk and new input from the perl script. +=item B<$RRDp::error_mode> and B<$RRDp::error> + +If you set the variable $RRDp::error_mode to the value 'catch' before you run RRDp::read a potential +ERROR message will not cause the program to abort but will be returned in this variable. If no error +occurs the variable will be empty. + + $RRDp::error_mode = 'catch'; + RRDp::cmd qw(info file.rrd); + print $RRDp::error if $RRDp::error; + =back @@ -89,7 +99,7 @@ For more information on how to use RRDtool, check the manpages. =head1 AUTHOR -Tobias Oetiker +Tobias Oetiker =cut #' this is to make cperl.el happy @@ -110,7 +120,7 @@ sub cmd (@); sub end (); sub read (); -$VERSION=1.199908; +$VERSION=1.2019; sub start ($){ croak "rrdtool is already running" @@ -128,6 +138,7 @@ sub start ($){ sub read () { croak "RRDp::read can only be called after RRDp::cmd" unless $Sequence eq 'C'; + $RRDp::error = undef; $Sequence = 'R'; my $inmask = 0; my $srbuf; @@ -148,9 +159,10 @@ sub read () { $minibuf .= $srbuf; while ($minibuf =~ s|^(.+?)\n||s) { my $line = $1; - # print $line,"\n"; - if ($line =~ m|^ERROR|) { - croak $line; + # print $line,"\n"; + $RRDp::error = undef; + if ($line =~ m|^ERROR|) { + $RRDp::error_mode eq 'catch' ? $RRDp::error = $line : croak $line; $ERR = 1; } elsif ($line =~ m|^OK u:([\d\.]+) s:([\d\.]+) r:([\d\.]+)|){