CDEF Function to find % value in Cacti

て烟熏妆下的殇ゞ 提交于 2019-12-11 11:45:55

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/1623143/cdef-function-to-find-value-in-cacti

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!