[rrd-users] integrate graphs on html

Simon Hobson linux at thehobsons.co.uk
Mon Aug 15 08:38:50 CEST 2011

David Thornton wrote:
>I personally like rrdcgi . It does a lot of stuff for you, but allows
>you to built the graph exactly as you want it.

Indeed it does.
My CGIs are written in Bash and have the following general arrangement :

extract options from URL
work out start and end times
output HTML header
   all the stuff to make the graph
) | /usr/bin/rrdcgi --filter - 2>&1 > /dev/null
cat ${graph}

The stuff to make the graph can be pretty much anything you want, 
just in a load of "echo" statements. Conditionals loop are easy, so 
it's fairly easy to build up large stacked areas using (for example) 
an array of the IP addresses to be included and a second array to 
cycle round with a list of colours to use.
As long as you end up outputting a complete graph definition.
${graph} needs to be a unique filename for each combination of input 
parameters, so if you just had timescale and max=on/off you might 
make "graph=<base>-${timescale}-${max}.png"

You can then build your web page along the lines of :
<headings and stuff>
<footers and stuff>

As soon as you bring up the page, the browser will call for each 
image, and your server will fire up (in this case) four copies of the 
script to generate the four graphs required. If you use the --lazy 
option, then some of the graphs will appear straight away and the 
others once they've been built.

>I was unable to build a graph with 100s of ds. I did not spend
>anytime trying to figure out if it was an rrd issue, an rrdcgi issue,
>or an issue with anyone of the various libraries that rrd uses. Ymmv

I have a graph with over 500 elements, and over 1000 items in the legend.

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