[rrd-users] adding DS values from multiple rrd files?
Simon Hobson
linux at thehobsons.co.uk
Tue Aug 3 20:49:38 CEST 2010
At 13:48 +0000 3/8/10, Joel wrote:
>Thanks guys!
>
>I think the part I'm struggling with is how to define the CDEF for
>the "total" variable inside a php foreach loop. I get errors about
>the CDEF being reused.
>
>Anyone out there doing rrdtool graphing with php?
I'm working in bash script, and piping the result of a load of echo
statements through rrdtool, but the the same principal should apply.
The actual code I've used is :
for direction in in out
do
for GraphIP in "${IPs[@]}"
do
[ ${GraphIP} -eq ${IPs[0]} ] \
&& echo -n " CDEF:data${direction}avg=${GraphIP}-${direction}" \
|| echo -n ",${GraphIP}-${direction},+"
done
echo "
VDEF:vdata${direction}avg=data${direction}avg,AVERAGE"
done
The end result is I send the following to rrdtool :
CDEF:data${direction}avg=ip0-in,ip1-in,+,ip5-in,+,ip10-in,+
So I keep adding more and more terms to an RPN expression inside the
loop. I vaguely recall it took me a long time to figure out stuff
like this when I was first writing these graphs.
--
Simon Hobson
Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.
More information about the rrd-users
mailing list