[rrd-users] Questions from a totally lost newbie

Bach Ho bachvanho at gmail.com
Wed Jul 11 18:46:44 CEST 2007


Hello,

    Let me preface by saying that I am new to the RRD Tool and that I
don't know what I'm doing. I've been struggling to get a simple script
working, but have failed. Below is a script where I try to create an
rrd, update it nine times, and then print out information proving that
the update is successful.

The script is:
*****

RRDp::start "/usr/bin/rrdtool";
RRDp::cmd qw(create demo1.rrd --step 3
       DS:in:GAUGE:6:U:U
       RRA:AVERAGE:0.5:1:10);

$rrd = "demo1.rrd";

RRDs::update ($rrd,"--template","in","N:1");
my $ERR=RRDs::error;
print "error: ".$ERR."<br>";
die "ERROR while updating ".$rrd.": $ERR\n" if $ERR
sleep 3;
RRDs::update ($rrd,"--template","in","N:2");
sleep 3;
RRDs::update ($rrd,"--template","in","N:3");
sleep 3;
RRDs::update ($rrd,"--template","in","N:4");
sleep 3;
RRDs::update ($rrd,"--template","in","N:5");
sleep 3;
RRDs::update ($rrd,"--template","in","N:6");
sleep 3;
RRDs::update ($rrd,"--template","in","N:7");
sleep 3;
RRDs::update ($rrd,"--template","in","N:8");
sleep 3;
RRDs::update ($rrd,"--template","in","N:9");

my $cur_time = time();
my $end_time = $cur_time;
my $start_time = $end_time - 9;

my ($start,$step,$ds_names,$data) = RRDs::fetch($rrd, "AVERAGE", "-r",
"600", "-s", $start_time, "-e", $end_time);

$length = @data;
print "length of data array: ".$length."<br>";

$lastupdate = RRDs::last;
print "last update".$lastupdate."<br>";

($averages,$xsize,$ysize) = RRDs::graph;
print "Imagesize: ${xsize}x${ysize}<br>";
print "Averages: ", (join ", ", @$averages);

$answer = RRDp::read;

print "<br>RRDp::read result: ".$$answer."<br>";

*****

    So it tries to print out 6 things:
1. any error result from trying to update the demo1.rrd the first time
2. the length of the array that is supposed to store rrd values
fetched for the previous nine seconds
3. the result of RRDs::last (the last update time?)
4. the X and Y axis results of a call to RRDs::graph
5. the "averages" result of a call to RRDs::graph (I don't know what
this information is supposed to be)
6. the result of a call to RRDp::read

The results for all 6 things are null - except for (2), where the
length of the array is zero. This tells me that the demo1.rrd isn't
being updated. I'd appreciate any input here.

Another question I have is how to delete an rrd? So far, I've been
creating new rrd's just to test my script, e.g. demo2.rrd, demo3.rrd,
etc.

Thank you,

Bach



More information about the rrd-users mailing list