[rrd-users] Generate rrd graph in real time
Rob Conway
rjconway at bigpond.com
Wed Jun 24 14:15:27 CEST 2009
Frankie,
I am not a web guru and tried to get a few times to get php installed with
the library and failed. I gave up and simply used a bash cgi script. The
trick for me was to send the output to >dev/null as the rrd graph gives an
output of trend size which stuffed up sending the file back to the web page.
When I rebuild my server and upgrade rrdtools I shall again try a php
library.
Check out www.rjconway.homeip.net the solution is very simply. The web
page source will show how I assemble the cgi arguments and I have included
my cgi file below.
This page also demonstrates using ajax to retrieve data and display it as
gauges. I have created these gauges from scratch however they could easily
be used for any type of application. The gauges are driven by the ability
of raphaeljs, a fantastic SVG type library. Send an email direct as I have
started a write-up on how the gauges work.
######################## CGI SCRIPT ON SERVER #####################
#!/bin/bash
## Strip HTML GET String into local variables ##
STIME=`echo "$QUERY_STRING" | sed -n 's/^.*stime=\([^&]*\).*$/\1/p' | sed
"s/%20/ /g"`
ETIME=`echo "$QUERY_STRING" | sed -n 's/^.*etime=\([^&]*\).*$/\1/p' | sed
"s/%20/ /g"`
HIGHSCALE=`echo "$QUERY_STRING" | sed -n 's/^.*highscale=\([^&]*\).*$/\1/p'
| sed "s/%20/ /g"`
LOWSCALE=`echo "$QUERY_STRING" | sed -n 's/^.*lowscale=\([^&]*\).*$/\1/p' |
sed "s/%20/ /g"`
WIDTH=`echo "$QUERY_STRING" | sed -n 's/^.*width=\([^&]*\).*$/\1/p' | sed
"s/%20/ /g"`
HEIGHT=`echo "$QUERY_STRING" | sed -n 's/^.*height=\([^&]*\).*$/\1/p' | sed
"s/%20/ /g"`
TRENDTYPE=`echo "$QUERY_STRING" | sed -n 's/^.*ttype=\([^&]*\).*$/\1/p' |
sed "s/%20/ /g"`
case "$TRENDTYPE" in
'ph')
## Aquarium PH GRAPH ##
rrdtool graph /var/www/aqua.png --start $STIME --end $ETIME \
--upper-limit $HIGHSCALE --lower-limit $LOWSCALE --slope-mode --units-length
2 \
--interlaced \
--rigid \
--width $WIDTH --height $HEIGHT \
--vertical-label "pH\n" \
--color CANVAS#000000 \
--title "Aquarium pH" \
DEF:phv=/var/www/rrd/aqua_ph.rrd:P1:AVERAGE LINE1:phv#0000FF:"Ph=" \
VDEF:phlast=phv,LAST GPRINT:phlast:"%3.2lf%S" \
VDEF:phavg=phv,AVERAGE GPRINT:phavg:"avg=%3.2lf%spH " \
--watermark "Aquarium PH Graph">/dev/null
;;
'orp')
## Aquarium ORP GRAPH ##
rrdtool graph /var/www/aqua.png --start $STIME --end $ETIME \
--upper-limit $HIGHSCALE --lower-limit $LOWSCALE --slope-mode --units-length
2 \
--interlaced \
--rigid \
--width $WIDTH --height $HEIGHT \
--title "Aquarium ORP" \
--vertical-label "mV" \
--color CANVAS#000000 \
DEF:orp=/var/www/rrd/aqua_orp.rrd:O1:AVERAGE \
LINE1:orp#FF3D0D:"Orp=" \
VDEF:orplast=orp,LAST GPRINT:orplast:"%4.0lf%smV" \
VDEF:orpavg=orp,AVERAGE GPRINT:orpavg:"avg=%4.0lf%smV" \
--watermark "Aquarium Orp / Conductivity Graph" >/dev/null
;;
esac
## Send output to web page ##
echo Content-type: image/png
echo
cat aqua.png
-----Original Message-----
From: rrd-users-bounces at lists.oetiker.ch
[mailto:rrd-users-bounces at lists.oetiker.ch] On Behalf Of frankie
Sent: Monday, June 22, 2009 11:33 PM
To: rrd-users at lists.oetiker.ch
Subject: [rrd-users] Generate rrd graph in real time
Hi all, I want to generate the graph realtime when the web page is visited
by someone similar to cacti . Is php-rrdtool is the only way to do it?
THX
--
View this message in context:
http://n2.nabble.com/Generate-rrd-graph-in-real-time-tp3136242p3136242.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.
_______________________________________________
rrd-users mailing list
rrd-users at lists.oetiker.ch
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.339 / Virus Database: 270.12.85/2193 - Release Date: 06/21/09
20:02:00
More information about the rrd-users
mailing list