[mrtg] RRDTOOL error

Gayan S. Amarasiri gayan.amarasiri at dialog.lk
Tue Dec 30 05:59:59 CET 2008


Hi,

 

I am using the following script to draw a graph using rrdtool. But it is
not displaying any value. When I check with "rrdtool fetch" command it
displayed as "nan". Please help on this.

 

 

use lib qw(/lib/perl/5.8.0/i386-linux-thread-multi/);

use RRDs;

#$dt= print localtime();

$ipadd="192.168.3.1" ;

sub trim($)

{

 my $string = shift;

 $string =~ s/^\s+//;

 $string =~ s/\s+$//;

 return $string;

}

 

sub gettrap{

$getval= join (" ", "snmpget -v2c -c admin" ,$ipadd,$_[0],"|");

open (SNMPGET,"$getval");

$val=<SNMPGET>;

chop($val);

return split (/:/ , $val);

}

 

sub castStrInt {

            my $t;

      foreach my $d (split(//, shift())) {

      $t = $t * 10 + $d;

      }

      return $t;

}

 

@in =gettrap("1.3.6.1.2.1.2.2.1.10.14");

@out= gettrap("1.3.6.1.2.1.2.2.1.16.14");

$kin=trim($in[3]);

$kout=trim($out[3]);

$intin=castStrInt($kin);

$intout=castStrInt($kout);

#system("rrdtool update /var/www/html/testrrd/myrouter.rrd
N:$intin:$intout");

#system("rrdtool update /var/www/html/testrrd/myrouter1.rrd
N:$intin:$intout");

RRDs::update ("myrouter.rrd", "N:$intin:$intout");

RRDs::graph ("myrouter-day.png","--start=-86400",
"DEF:inoctets=myrouter.rrd:input:AVERAGE",
"DEF:outoctets=myrouter.rrd:output:AVERAGE", "AREA:inoctets#FF00ff:In
traffic", "LINE1:outoctets#FF00FF:Out traffic");

 

Thanks & BR,

Gayan Amarasiri

 

 

 

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
**********************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20081230/09507936/attachment.html 


More information about the mrtg mailing list