[rrd-users] rrdtool perl interface from 1.0 to 1.2

Xavier Beaudouin kiwi at oav.net
Mon Nov 26 14:30:35 CET 2007


Hello,

I am trying to migrate some rrdtool scripts from a smokeping based on 
rrdtool 1.0 to rrdtool 1.2 based.

Migration are ok but it seems that RRDs perl library (and maybe rrdtool 
itself also) has some woes with last update data.

I used theses scripts to check some data from Smokeping and send alert in 
Nagios is there is more than x% losts packets.

Sample idea :

rrdtool last <rrdfile>
rrdtool fetch <rrdfile> AVERAGE -s <value from last>

This was working... on 1.0.49 without any pain.

Now on 1.2.19 (backport from debian SID to Etch) the script doesn't work 
at all and it seems that rrdtool last gave some random values because when 
I do rrdtool fetch ... I allways got nan value in return.

I have saw that is rrdtools lastupdate, but it is not yet implemented into 
RRDs perl library.

Any hints ? idea ? Fixes ?

Script used :

---//---
#!/usr/bin/perl -w
use RRDs;
use strict;

$ENV{'PATH'} = "/bin:/usr/bin";
$ENV{'ENV'} = "";

if (scalar @ARGV != 3) {
         print STDERR join "' '", @ARGV, "\n";
         print "not enough argument\n";
         exit;
}

my $rrd = $ARGV[0] if (-r $ARGV[0]);
my $warn= $ARGV[1];
my $crit=$ARGV[2];
my ($last) = RRDs::last ($rrd);

my ($start,$step,$names,$data) = RRDs::fetch ($rrd,"AVERAGE","-s",$last);
my $line= @$data[0];
my $nbloss=@$line[1]

if($nbloss >= $crit)
{
  printf "RRD CRITICAL too much packet loss or failed to connect.Lost pack
et : %4.2f packets\n", $nbloss;
         exit 2;
}
else
{

         if( $nbloss >= $warn )
         {
                 printf "RRD WARNING.Lost packet : %4.2f packets\n", 
$nbloss;
                 exit 1;
         }
         else
         {
                 printf "RRD OK.Lost packet :%4.2f packet\n", $nbloss;
                 exit 0;
         }
}
---//----

See that it is quite simple...


Thanks,
/Xavier

--
Xavier Beaudouin - http://oav.net/



More information about the rrd-users mailing list