CDEF Function to find % value in Cacti
I am trying to figure out how to find the % based on two data sources from an RRD graph. Below is the code used to create the graph (generated by Cacti)
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=1256445701 \
--end=1256532101 \
--title="Message Size" \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
COMMENT:"From 2009/10/25 14\:41\:41 To 2009/10/26 14\:41\:41\c" \
COMMENT:" \n" \
--vertical-label="" \
--slope-mode \
--font TITLE:10: \
--font AXIS:8: \
--font LEGEND:8: \
--font UNIT:8: \
DEF:a="/srv/www/vhosts/cacti/cacti-0.8开发者_开发知识库.7d/rra/5393.rrd":dsAttachmentSize:AVERAGE \
DEF:b="/srv/www/vhosts/cacti/cacti-0.8.7d/rra/5393.rrd":dsSIAttachmentSize:AVERAGE \
CDEF:cdefa=a,1000000,* \
CDEF:cdefe=b,1000000,* \
AREA:cdefa#0000aaFF:"Attach Size" \
GPRINT:cdefa:LAST:" Current\:%8.2lf %s" \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s\n" \
AREA:cdefe#FF0000FF:"Attach SI Size" \
GPRINT:cdefe:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefe:MAX:"Maximum\:%8.2lf %s\n"
I would like to find the following (A - B) / A * 100 and display it at the bottom of the graph.
I think this question is more programming related then server related (but I am ready to stand corrected), if anyone can point me to some good documentation on RRD to figure this out myself or if anyone can give me a good start it would be greatly appreciated.
Cheers.
This was a relatively easy one in the end. Just create a CDEF function like the following.
a,b,-,a,/,100,*
And assign that CDEF function to a graph item without a datasource.
精彩评论