[rrd-users] adding DS values from multiple rrd files?

Tristan Hoar tristan.hoar at bgfl.org
Tue Aug 3 15:36:22 CEST 2010

On 03/08/2010 13:54, Joel Brooks wrote:
> hey gang,
> I'm trying to create a graph that uses a datasource from a number of
> different rrd files to show total items in the queue.
> I have the graph working, but I want to add a legend item that shows the
> total.
> right now, the graph (a stacked graph) shows a different band for each
> server and the legend displays the text "<server name> <X>  messages in
> the queue".
> but how can i add up all the values so i can print "total <X> messages
> in the queue"?
> i'm doing this on a php page if that helps/matters.  I have a foreach
> loop that extracts the ds value for each server in a list.
> (rrdtool = 1.3.8)
> thanks!
> thanks!
> J

Hi Joel,

This is an example of how I do it for some of our servers. The bit your 
interested in is cdef cdefda and cdefdb, here I add both data sources 
together and then in the grpint I call those cdefs and not the standard 
defs to show my combined totals.



rrdtool graph /var/www/html/misc/pict.png \
--title="Vend MB/s" \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale \
--vertical-label="MB/s" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
--color CANVAS#000000 \
--color BACK#444444 \
--color FONT#BBBBBB \
DEF:b="/usr/share/cacti/rra/97.rrd":Client_KBs:MAX \
DEF:c="/usr/share/cacti/rra/99.rrd":Client_KBs:MAX \
DEF:be="/usr/share/cacti/rra/98.rrd":Proxy_KBs:MAX \
DEF:bf="/usr/share/cacti/rra/100.rrd":Proxy_KBs:MAX \
CDEF:cdefb=b,1024,* \
CDEF:cdefc=c,1024,* \
CDEF:cdefbe=be,-1024,* \
CDEF:cdefbf=bf,-1024,* \
AREA:cdefb#004359FF:"Lib1" \
AREA:cdefc#005D57FF:"Lib2\n":STACK \
AREA:cdefbe#004359FF:"" \
AREA:cdefbf#005D57FF:"":STACK \
GPRINT:cdefda:LAST:"TOTAL Out - Current\:%8.2lf %sBs" \
GPRINT:cdefda:AVERAGE:"Avg\:%8.2lf %sBs" \
GPRINT:cdefda:MAX:"Max\:%8.2lf %sBs\n" \
GPRINT:cdefdb:LAST:"TOTAL In - Current\:%8.2lf %sBs" \
GPRINT:cdefdb:AVERAGE:"Avg\:%8.2lf %sBs" \
GPRINT:cdefdb:MAX:"Max\:%8.2lf %sBs\n" \

This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity 
to whom they are addressed. If you have received this email 
in error please notify postmaster at bgfl.org

The views expressed within this email are those of the 
individual, and not necessarily those of the organisation

More information about the rrd-users mailing list