[rrd-users] Bug in rrdtool?

Jean-Yves Avenard jyavenard at gmail.com
Sat Dec 26 08:37:25 CET 2009


Hi

Merry Christmas to all of you reading ...

Stretching the limit of rrdtool today ; I encountered an error I
hadn't seen before:
"ERROR: malloc im->gdes[gdi].data"

I was trying to plot monthly data; from the 1st to the end of each
month ; like from 1/1/2009 to 31/1/2009, then 1/2/2009 to 28/2/2009
etc...

All good until I tried to calculate the average.
Here is a portion of the relevant code (in  PHP)
At the time rrdtool is started ; the variable $month is a 2 dimensions array.
$month[0] is for the current month ; with [0] being the start
timestamp, and [1] being the end timestamp.
then you get the previous 11 month

So being in Decembe, for example $month[3][1]  is the end timestamp
for the month of September.

$cmd = "$RRDTOOL graph $name -l 0 \
-t '$title' \
-x $legend  --slope-mode \
--step $res --start $start --end $timestamp \
-w $width -h $height ";

for ($i=0; $i<12; $i++) {
   $cmd .= "DEF:ext{$i}=$EXTRRD2:total:AVERAGE:start={$month[$i][0]}:end={$month[$i][1]}
\
    VDEF:vext{$i}tot=ext{$i},TOTAL \
    CDEF:cext{$i}=ext{$i},POP,vext{$i}tot ";
}

$cmd .=  "COMMENT:'        ' \
 COMMENT:'Maximum  ' \
    COMMENT:'Average  ' \
    COMMENT:'Minimum      '  \
    COMMENT:'Total\l' ";

for ($i=0; $i<12; $i++) {
   $cmd .= "AREA:cext{$i}#$COLOUR[ext]" . ($i == 0 ? ":'$LABEL[ext]' " : " ");
}

$cmd .= "DEF:ext=$EXTRRD2:total:AVERAGE VDEF:vexttot=ext,TOTAL ";

$cmd .= "CDEF:cext=cext0,cext1,+,cext2,+,cext3,+,cext4,+,cext5,+,cext6,+,cext7,+,cext8,+,cext9,+,cext10,+,cext11,+
";

$ret = exec($cmd . " > /dev/null", $output2, $status2);

----

To calculate the monthly maximum , minimum and average ; I thought of
simply adding each CDEF together. Forgetting the validity of that
thought (it isn't valid as it would always result in UNKNOWN at all
points)

Googling for this error had related topics ; usually pointing to a
lack of memory. This machine is a 64 bits linux (Ubuntu 9.10) and 4GB
of RAM.

It's that line $cmd .=
"CDEF:cext=cext0,cext1,+,cext2,+,cext3,+,cext4,+,cext5,+,cext6,+,cext7,+,cext8,+,cext9,+,cext10,+,cext11,+
";
that generates a malloc error.
the RRD file is 14MB is size (for 5 years, 5 minutes average of data).
So having a RAM issue seems unlikely...

Trying to localise the error ;
having a CDEF with:
"CDEF:cext=cext0,cext1,+" will work
having a CDEF with:
"CDEF:cext=cext0,cext1,+,cext2,+" will *not*

(the exact thing I had tried was having:
$cmd .= "CDEF:cext=cext0,UN,0,cext0,IF,cext1,UN,0,cext1,IF,+,cext2,UN,0,cext2,IF,+
";

But it can be reproduced with much simpler CDEF like mentioned above
)

Cheers
Jean-Yves



More information about the rrd-users mailing list