[rrd-users] another newbie question (sorry this is kind of long)

Daniel Patrick Sullivan dansullivan at gmail.com
Sat Nov 12 03:59:43 CET 2011

HI, rrd-users,

Sorry I have a very newbie question here.  Basically I am manually
updating an rrd file with some perl code that basically reflects the
perl code on the website.  I am certain that the values I am inputting
into the rrd are actually integers, as I set the script to echo to the
local terminal and ran it in the foreground.  The output looks like

# ./update_physical_memory.sh
updated this iteration: 69313
Fri Nov 11 14:47:03 CST 2011

updated this iteration: 69633
Fri Nov 11 14:48:00 CST 2011

My script that updates my files is nothing crazy.  It looks like this:

while [ "$a" == 0 ]; do
        consumption=$(snmpwalk -v 1 -m ALL -c public localhost \
                 . | awk '{ print $4 }')
        /usr/local/bin/rrdtool update /root/rrd/physicalmemory.rrd
        echo "updated this iteration: $consumption"
        perl -e 'sleep 60 - time % 60'
done # end of while loop

In addition to this syntax, my rrdcreate syntax looks like this:

rrdtool create physicalmemory.rrd --step 60 \
DS:physicalmem:GAUGE:600:1:300000 \
RRA:AVERAGE:0.5:1:5000 \
RRA:MIN:0.5:60:2400 \
RRA:MAX:0.5:60:2400 \

So, as you can see, I'm not doing anything too crazy.  What I'm
confused about is that when I read the data back from the database via
a perl script (or via rrddump), it is not showing up as an integer.  I
understand the concept of scientific notation, however I am uncertain
as to why it appears that a longer number than the number of digits in
the actual values are being inserted are coming from.  Can somebody
explain where all of the extraneous digits in these values are coming
from?  I would expect the numbers to be around six digits long (for
example, 69633); The beginning of my rrdump looks like this:

                        <!-- 2011-11-08 03:34:00 CST / 1320744840 -->
<row><v> 7.2850015968e+04 </v></row>
                        <!-- 2011-11-08 03:35:00 CST / 1320744900 -->
<row><v> 7.2855900089e+04 </v></row>
                        <!-- 2011-11-08 03:36:00 CST / 1320744960 -->
<row><v> 7.2941940641e+04 </v></row>
                        <!-- 2011-11-08 03:37:00 CST / 1320745020 -->
<row><v> 7.2944995993e+04 </v></row>
                        <!-- 2011-11-08 03:38:00 CST / 1320745080 -->
<row><v> 7.2888106579e+04 </v></row>
                        <!-- 2011-11-08 03:39:00 CST / 1320745140 -->
<row><v> 7.2886005085e+04 </v></row>

Also, when I read these back in a perl script, using RRDs::fetch for
example, they are appearing as decimal numbers;

My code basically looks like this:

my ($start,$step,$ds_names,$data) = RRDs::fetch("physicalmemory.rrd",
"AVERAGE", "-s", "$start_time", "-e", "$end_time");
foreach my $line (@$data) {
        $vals[$rows][$columns] = $time_variable;
        $time_variable = $time_variable + $step;
        foreach my $val (@$line) {
                $vals[$rows][++$columns] = $val;
                if ($val) {
                        print "row: $rows, $columns, $val\n";
                } else {
                        print "The value didn't exist\n";
        $columns = 0;

When the $val actually gets echoed back, I am seeing values such as this:

row: 498, 1, 66511.9314268389

Can somebody please explain to me why I seem to be inserting integers
however decimal values are being echoed back?


Dan Sullivan

More information about the rrd-users mailing list