[rrd-users] rrdcgi

Simon Hobson linux at thehobsons.co.uk
Wed Apr 17 11:07:48 CEST 2013

Ed Donahue III wrote:
>I am trying to create graphs via rrdcgi and I get 500 error, I can 
>create the graphs via rrdtool graph, but I want them run in real-time 
>(when user refreshes the page):

I gave up on trying to get that working (but it was a long time, and quite a few versions, ago). I wrote some CGI scripts in BASH to wrap round it, like this (it's not pretty, but it was written a while ago and comes under the category of "works, so don't fix it") :

<stuff that processes options from URL, reads config files, and sets script variables>

Etime=`/bin/date +%s`
Etime=$(( ${Etime} / ${Step} * ${Step} ))
PrintedTime=$(/bin/date -d "19700101 00:00 +0000 ${Etime}sec" +"%H\:%M %a %d %b %Y")
Exptime=$(( ${Etime} + ${Step} ))
 echo "Content-Type: image/png
Last-Modified: `date --rfc-2822 -d "19700101 00:00 +0000 ${Etime}sec"`
Expires: `date --rfc-2822 -d "19700101 00:00 +0000 ${Exptime}sec"`

<stuff that generates RRD script> \
 | /usr/bin/rrdcgi --filter - > /dev/null

cat ${GraphPath}/${GrFile}-${Max}-${TimeScale}.png

Then I can call it with http://myserver/<stuff>.cgi?<options>&timescale=day to get a one day graph, with options for week, month, year. I use the --lazy option to RRD so it doesn't need to generate images that haven't updated, and the Expires: header tells the browser how long it should cache the image for.

More information about the rrd-users mailing list