[rrd-users] Cant quite get data sample correct.

Martin Rheumer martinr at hotkey.net.au
Mon Feb 12 15:42:15 CET 2007


Peeps,

Am starting to write some rrdtool files manually again, and 
am pretty sure Im donig something stupid. The following script
was borrowed from archives and retrieves a set of values from
a mysql database and creates an rrd file for each ATM trunk
we have. 
Please ignore the code ( its perl but changed to protect the 
innocent coder )


   my $STEP  = 300;

   my $START = "19970101";

   my @options = ("-b", $START, "-s", $STEP,
    "DS:ds0:GAUGE:300:U:U",
    "DS:ds1:GAUGE:300:U:U",
    "RRA:AVERAGE:0.5:1:999",
    "RRA:AVERAGE:0.5:6:800",
    "RRA:AVERAGE:0.5:24:800",
    "RRA:AVERAGE:0.5:288:800",
    "RRA:MIN:0.5:1:999",
    "RRA:MIN:0.5:6:800",
    "RRA:MIN:0.5:24:800",
    "RRA:MIN:0.5:288:800",
    "RRA:MAX:0.5:1:999",
    "RRA:MAX:0.5:6:800",
    "RRA:MAX:0.5:24:800",
    "RRA:MAX:0.5:288:800");

   print "* Creating RRD $RRD1 starting at e.\n\n";
   RRDs::create $RRD1, @options;

   my $ERROR = RRDs::error;
   ok("create A", !$ERROR);                        #  2
   if ($ERROR)
   {
      die "$0: unable to create `$RRD1': $ERROR\n";
   }

   print "* Filling $RRD1 with values. One moment please ...\n";

   while %hash2-Query("select unix_timestamp(run_date) as
Unixtime_run_date, totald from trunk where name =
'tsv_cn_1.bne_cs_2.tot_cells.in")
   {
      $t = $hash2{Unixtime_run_date};
      $data1 = $hash2{totaldata};
      print "\n$RRD1 \t $t:$data1:$data1\n";
      RRDs::update $RRD1, "$t:$data1:$data1";
      if ($ERROR = RRDs::error)
      {
          die "$0: unable to update `$RRD1': $ERROR\n";
      }
   }

The outout looks like this.

/usr/local/mrtg/htdocs/atm_stats/tsv_cn_1.bne_cs_2.tot_cells.in.rrd
1171253700:439670:439670
/usr/local/mrtg/htdocs/atm_stats/tsv_cn_1.bne_cs_2.tot_cells.in.rrd
1171254000:176465:176465
/usr/local/mrtg/htdocs/atm_stats/tsv_cn_1.bne_cs_2.tot_cells.in.rrd
1171254300:188213:188213



Now when I go and query the tsv_cn_1.bne_cs_2.tot_cells.in with rrdtool
fetch I get 

rrdtool fetch tsv_cn_1.bne_cs_2.tot_cells.in.rrd -s 1171253700 -e +10h AVERAGE
                            ds0                 ds1

1171324800: nan nan

The graphs are also very blocky and appear in 30 minute samples, where I
clearly have
5 minute data samples for the past 24 hours.

Can someone see what I have / am doing wrong. 

This has driven me mad all day today..

Thanks again
Martin







More information about the rrd-users mailing list