Mod rrdtool » History » Revision 16
Revision 15 (Anonymous, 2008-06-16 03:31) → Revision 16/19 (stbuehler, 2009-02-17 11:40)
h1. Module [[TracNav(DocsToc)]] <pre> #!rst ======= rrdtool ======= ------------------- Module: mod_rrdtool ------------------- {{toc}} h2. .. contents:: Table of Contents Description =========== "RRD":http://oss.oetiker.ch/rrdtool/ RRD_ is a system to store and display time-series data (i.e. network bandwidth, machine-room temperature, server load average). h2. Warning .. _RRD: http://oss.oetiker.ch/rrdtool/ * This module will not work if you are using more than one worker ("server.max-worker":Server.max-workerDetails) h2. Options ======= h3. rrdtool.binary path to the rrdtool binary e.g.: :: rrdtool.binary = "/usr/bin/rrdtool" h3. rrdtool.db-name filename of the rrd-database. Make sure that <rrdtool.db-name> doesn't exist before the first run, as lighttpd has to create the DB for you. e.g.: :: rrdtool.db-name = "/var/www/lighttpd.rrd" h2. Generating Graphs ================= Four things must be done to generate graphs: *Alternative*: 1. Enable the mod_rrdtool in lighttpd.conf (as above) **Alternative**: Instead of the last following three steps (2,3,4), just can use attachment:lightygraph.cgi `lightygraph.cgi <http://trac.lighttpd.net/trac/attachment/wiki/Docs/ModRRDTool/lightygraph.cgi>`_ to automatically generate the graphs as needed -- on the fly! # Enable the mod_rrdtool in lighttpd.conf (as above) # 2. Create/Edit the script provided below (as it generates the graphs). I call it rrdtool.sh, make sure you have eXecute permissions on it (chmod +x) # 3. Create an HTML page to output the images (provided at the end bottom) # 4. Run the script and add to cron. <pre> Cron. 0,20,40 * * * * nice -n 10 /etc/lighttpd/rrdtool.sh >& /dev/null </pre> Note: Ubuntu fiesty and later remove the & from >& above for cron to run. /bin/sh is linked to /bin/dash and expects a file descriptor rather than a path to send the output to. (bad fd error otherwise) h3. rrdtool.sh :: #!/bin/sh RRDTOOL=/usr/bin/rrdtool OUTDIR=/var/www/servers/www.example.org/pages/rrd/ INFILE=/var/www/lighttpd.rrd OUTPRE=lighttpd-traffic DISP="-v bytes --title TrafficWebserver \ DEF:binraw=$INFILE:InOctets:AVERAGE \ DEF:binmaxraw=$INFILE:InOctets:MAX \ DEF:binminraw=$INFILE:InOctets:MIN \ DEF:bout=$INFILE:OutOctets:AVERAGE \ DEF:boutmax=$INFILE:OutOctets:MAX \ DEF:boutmin=$INFILE:OutOctets:MIN \ CDEF:bin=binraw,-1,* \ CDEF:binmax=binmaxraw,-1,* \ CDEF:binmin=binminraw,-1,* \ CDEF:binminmax=binmax,binmin,- \ CDEF:boutminmax=boutmax,boutmin,- \ AREA:binmin#ffffff: \ STACK:binminmax#f00000: \ LINE1:binmin#a0a0a0: \ LINE1:binmax#a0a0a0: \ LINE2:bin#a0a735:incoming \ GPRINT:bin:MIN:%.2lf \ GPRINT:bin:AVERAGE:%.2lf \ GPRINT:bin:MAX:%.2lf \ AREA:boutmin#ffffff: \ STACK:boutminmax#00f000: \ LINE1:boutmin#a0a0a0: \ LINE1:boutmax#a0a0a0: \ LINE2:bout#a0a735:outgoing \ GPRINT:bout:MIN:%.2lf \ GPRINT:bout:AVERAGE:%.2lf \ GPRINT:bout:MAX:%.2lf \ " $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP OUTPRE=lighttpd-requests DISP="-v req --title RequestsperSecond -u 1 \ DEF:req=$INFILE:Requests:AVERAGE \ DEF:reqmax=$INFILE:Requests:MAX \ DEF:reqmin=$INFILE:Requests:MIN \ CDEF:reqminmax=reqmax,reqmin,- \ AREA:reqmin#ffffff: \ STACK:reqminmax#0e0e0e: \ LINE1:reqmin#a0a0a0: \ LINE1:reqmax#a0a0a0: \ LINE2:req#00a735:requests" $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP </pre> *This script outputs better res graphics* <pre> #!/bin/sh RRDTOOL=/usr/bin/rrdtool OUTDIR=/var/www/www.example.com/rrd/ INFILE=/var/www/lighttpd.rrd OUTPRE=lighttpd-traffic WIDTH=400 WIDTH=600 HEIGHT=100 HEIGHT=350 DISP="-v bytes --title TrafficWebserver \ DEF:binraw=$INFILE:InOctets:AVERAGE \ DEF:binmaxraw=$INFILE:InOctets:MAX \ DEF:binminraw=$INFILE:InOctets:MIN \ DEF:bout=$INFILE:OutOctets:AVERAGE \ DEF:boutmax=$INFILE:OutOctets:MAX \ DEF:boutmin=$INFILE:OutOctets:MIN \ CDEF:bin=binraw,-1,* \ CDEF:binmax=binmaxraw,-1,* \ CDEF:binmin=binminraw,-1,* \ CDEF:binminmax=binmaxraw,binminraw,- \ CDEF:boutminmax=boutmax,boutmin,- \ AREA:binmin#ffffff: \ STACK:binmax#f00000: \ LINE1:binmin#a0a0a0: \ LINE1:binmax#a0a0a0: \ LINE2:bin#efb71d:incoming \ GPRINT:bin:MIN:%.2lf \ GPRINT:bin:AVERAGE:%.2lf \ GPRINT:bin:MAX:%.2lf \ AREA:boutmin#ffffff: \ STACK:boutminmax#00f000: \ LINE1:boutmin#a0a0a0: \ LINE1:boutmax#a0a0a0: \ LINE2:bout#a0a735:outgoing \ GPRINT:bout:MIN:%.2lf \ GPRINT:bout:AVERAGE:%.2lf \ GPRINT:bout:MAX:%.2lf \ " $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP -w $WIDTH -h $HEIGHT OUTPRE=lighttpd-requests DISP="-v req --title RequestsperSecond -u 1 \ DEF:req=$INFILE:Requests:AVERAGE \ DEF:reqmax=$INFILE:Requests:MAX \ DEF:reqmin=$INFILE:Requests:MIN \ CDEF:reqminmax=reqmax,reqmin,- \ AREA:reqmin#ffffff: \ STACK:reqminmax#00f000: \ LINE1:reqmin#a0a0a0: \ LINE1:reqmax#a0a0a0: \ LINE2:req#00a735:requests" $RRDTOOL graph $OUTDIR/$OUTPRE-hour.png -a PNG --start -14400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-day.png -a PNG --start -86400 $DISP -w $WIDTH -h $HEIGHT $RRDTOOL graph $OUTDIR/$OUTPRE-month.png -a PNG --start -2592000 $DISP -w $WIDTH -h $HEIGHT </pre> h3. Webpage *Webpage that displays outputs the graphics graphics* <pre> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Lighttpd traffic & requests</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="content-style-type" content="text/css"> <style type="text/css"> <!-- div { text-align:center; } img { width:693px; height:431px; } --> </style> </head> <body> <div> <h2>Lighttpd Traffic</h2> <img src="lighttpd-traffic-hour.png" alt="graph1"><br> <img src="lighttpd-traffic-day.png" alt="graph2"><br> <img src="lighttpd-traffic-month.png" alt="graph3"><br> </div> <div> <h2>Lighttpd Requests</h2> <img src="lighttpd-requests-hour.png" alt="graph4"><br> <img src="lighttpd-requests-day.png" alt="graph5"><br> <img src="lighttpd-requests-month.png" alt="graph6"><br> </div> </body> </html> </pre> h2. h1. Problems *** is has a pipe open all the time *** it doesn’t handle a restart *** doesn’t work with max-worker from http://blog.lighttpd.net/articles/2007/04/10/about-perfection-deprecacting-mod_rrdtool