[rrd-users] Supressing RRDTool "OK" message in pipe mode
Simon Hobson
linux at thehobsons.co.uk
Fri Feb 27 22:48:53 CET 2009
Phix wrote:
>The reason I am using RRDTool in pipe mode is because I have reached the
>command line argument limit of my shell (I have over 2000 DEF statements, to
>give you an idea of the number of RRD files I am dealing with). My only
>option here is to use RRDTool's pipe method, and then pipe my lengthy
>RRDTool graph definition into RRDTool STDIN and read the binary PNG stream
>on RRDTool's STDOUT.
Ditto - some of these graph definitions can get "quite large" ! One
of mine has up to 508 stacked areas (254 in, 254 out), and each
element also has two values (ave and max) printed in the legend. Each
data source is actually two files - selected with an "if date <
something use this one, else use the other" bit of processing.
The other factor is that virtually all of my graphs are variable in
content - so they are generated "on the fly" according to parameters
passed into the script. Eg, one graph can plot the traffic in and out
for a single IP (so the IP needs passing), and it can do it with or
without MAX lines (so another parameter). The script simply has a
"${IP}" where required, and an "if then <stuff> else <other stuff>"
block to draw the graph with or without lines for MAX.
I did try various other options - building up the graph def in a
variable (very slow), building it up in a file on disk (works but not
very elegant), and I finally settled on (this is an extract from a
script graphing various UPS parameters) :
>DoVolt () {
> echo "${RRDHead}
> --alt-autoscale
>
> DEF:ip_v_ave=${RRDPath}/${RRDName}:ip_v:AVERAGE
> DEF:ip_v_min=${RRDPath}/${RRDName}:ip_v_min:MIN
> DEF:ip_v_max=${RRDPath}/${RRDName}:ip_v_max:MAX
> CDEF:ip_v_spread=ip_v_max,ip_v_min,-
> VDEF:v_ip_v_ave=ip_v_ave,AVERAGE
> VDEF:v_ip_v_max=ip_v_max,MAXIMUM
> VDEF:v_ip_v_min=ip_v_min,MINIMUM
>
> DEF:op_v_ave=${RRDPath}/${RRDName}:op_v:AVERAGE
> DEF:op_v_min=${RRDPath}/${RRDName}:op_v:MIN
> DEF:op_v_max=${RRDPath}/${RRDName}:op_v:MAX
> CDEF:op_v_spread=op_v_max,op_v_min,-
> VDEF:v_op_v_ave=op_v_ave,AVERAGE
> VDEF:v_op_v_max=op_v_max,MAXIMUM
> VDEF:v_op_v_min=op_v_min,MINIMUM
>
> COMMENT:\" min ave max\n\"
> AREA:ip_v_min#FFFFFF00:
> AREA:ip_v_spread#FF00003F::STACK
> LINE1:ip_v_ave#FF0000:\"Input Volts \"
> GPRINT:v_ip_v_min:\"%6.1lf \"
> GPRINT:v_ip_v_ave:\"%6.1lf \"
> GPRINT:v_ip_v_max:\"%6.1lf\n\"
>
> AREA:op_v_min#FFFFFF00:
> AREA:op_v_spread#0000FF3F::STACK
> LINE1:op_v_ave#0000FF:\"Output Volts\"
> GPRINT:v_op_v_min:\"%6.1lf \"
> GPRINT:v_op_v_ave:\"%6.1lf \"
> GPRINT:v_op_v_max:\"%6.1lf\"
>
>
> COMMENT:\" Data to ${PrintedTime}\n\"
> >
>"
>}
>RRDHead="
> <RRD::GRAPH ${GraphPath}/ups-${GType}-${TimeScale}.png
> --title=\"${Heading} - ${TimeScaleHead}\" -v \"${YAxis}\"
> --end ${Etime} --start end-${Period}
> --width 600 --height ${Height:-200}
> --lazy
>"
>
>case ${GType} in
> volt ) DoVolt ;;
> current ) DoCurrent ;;
> power ) DoPower ;;
> pcp ) DoPCPower ;;
> pf ) DoPF ;;
> batvolt ) DoBatVolt ;;
> batcurrent ) DoBatCurrent ;;
> tture ) DoTemperature ;;
> batcap ) DoBatCap ;;
>esac | /usr/bin/rrdcgi --filter - 2>&1 > /dev/null
>
>
>cat ${GraphPath}/ups-${GType}-${TimeScale}.png
Naturally, there are a pile of case statements to determine what the
various variables need to be.
Perhaps not the most elegant, but "it works for me" !
--
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