perl script generate Nan time to time

General discussion about Plugins for Cacti

Moderators: Developers, Moderators

Post Reply
mmanojsri
Posts: 2
Joined: Sat Nov 08, 2008 2:24 pm
Location: Sri Lanka

perl script generate Nan time to time

Post by mmanojsri »

I have created a perl script to add RRDs and return values to back to cacti.

My script :
==============================================
#!/usr/bin/perl

$st=qx(date +%s)-1500;
$out_put[0] = 0;
$out_put[1] = 0;
$rrd[0] = "/var/www/html/cacti/rra/pp1_traffic_in_4450.rrd";
$rrd[1] = "/var/www/html/cacti/rra/pp1_traffic_in_473.rrd";
$rrd[2] = "/var/www/html/cacti/rra/pp1_traffic_in_4552.rrd";
$rrd[3] = "/var/www/html/cacti/rra/pp2_traffic_in_1481.rrd";
$rrd[4] = "/var/www/html/cacti/rra/pp2_3967.rrd";
$rrd[5] = "/var/www/html/cacti/rra/pp3_traffic_in_4554.rrd";
$rrd[6] = "/var/www/html/cacti/rra/pe3_traffic_in_2377.rrd";
$rrd[7] = "/var/www/html/cacti/rra/pe4_traffic_in_1426.rrd";
$rrd[8] = "/var/www/html/cacti/rra/pe4_traffic_in_3950.rrd";
$rrd[9] = "/var/www/html/cacti/rra/pe5_traffic_in_1397.rrd";
$rrd[10] = "/var/www/html/cacti/rra/pe5_traffic_in_2826.rrd";

foreach $current_rrd (@rrd)
{
@result = split(/_/, qx(/bin/rrdtool fetch $current_rrd AVERAGE -s $st | sed '1,2d' | sed '/nan/d' | awk '{printf(\$2 "," \$
3 "_")}' ));
@value = split(/,/, $result[$#result]);
@out_put = ($value[0] + $out_put[0] , $value[1] + $out_put[1]);
}

print "traffic_in:$out_put[0] traffic_out:$out_put[1]";
==============================================

script working fine and generate the required output but there are lot of blank spaces in the graph and the time to time rrd get updated with Nan values.

I try to analyze the issue buy logging the script out puts to a file and found that the script always return a value but rrd not updated with the correct value.

Please help me to resolve this issue
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests