Below a script that demonstrates an "ABSOLUTE" counter for counting e-mail messages (spam in this case). I posted it, because I couldn't find any satisfactory examples of ABSOLUTE and as a chance to get feedback from others and possibly help others. It seems to work fine, but I'm not an experienced rrdtool user, so if other users have tips or find bugs please respond.
Thx. JM =================================== #!/bin/bash ## ## Start this script in am empty dir (just in case because it creates ## some files) and then open simulate.html in your favorite browser. DAY=10 GENERATIONS=60 PERIOD=$(($DAY * $GENERATIONS)) ## Create self refreshing html-page cat > simulation.html << EOF <HTML> <HEAD> <TITLE>Sim</TITLE> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=simulation.html"> </HEAD> <BODY> <img src=simgraph.gif> <P>The graph above shows a simulation of the number of spam messages (red bars) I receive each day. The short blue stacked bars are false negatives, meaning messages that were not filtered out by the spam filter, but manually identified as spam later on*. <P>This simulation uses a 10 second "day" for the obvious reason that a real time simulation would take too long. The script as a whole is not useable in this form**. You'll have to split it up in a create, update and a graph piece. Set DAY to 86400 (seconds). The current number of generations would result in about 2 Months of data. Make sure you manually expand the shell variables or put them in a separate script and include that script in all the pieces. (Too include a script use this statement: ". /scriptpath/scriptname" without the quotes.) Btw: <I>bash</I> is needed, because of the calculations in the script. HTH for those people that are too lazy, like me, to read the <I>excellent</I> documentation that comes with rrdtool. You really should read it, but I posted this because I couldn't find any satisfactory examples of "ABSOLUTE" counters. <BR> ------- <BR>* These are moved to a specific folder and then automatically collected by a script, which feeds them to the spam filter to learn from. The same script updates rrdb. <BR>** This was first developed as a simulation to find out if every was working and put to use in the real world later. 24 Hour debug cycles aren't a lot of fun! </BODY> </HTML> EOF ## Create rrdb rrdtool create sim.rrd --start 'N' --step $DAY \ DS:sim:ABSOLUTE:$DAY:0:U \ DS:unk:ABSOLUTE:$DAY:0:U \ RRA:AVERAGE:0.1:1:$GENERATIONS ## Can update only once per second. Avoid writing too soon. sleep 1 while [ 1 ] ; do ## Feed simulated data to the rrdb MSG=$((RANDOM % 4)) if [ $MSG == 0 ] ; then UNK=$((RANDOM % 2)) else UNK=0 fi ## Allow pausing updates for a while, eg.: > stop; sleep 10; rm -f stop if [ -f stop ] ; then sleep 10; fi rrdtool update sim.rrd N:$MSG:$UNK rrdtool graph tmpgraph.gif --start -$PERIOD \ DEF:vsim=sim.rrd:sim:AVERAGE \ DEF:vunk=sim.rrd:unk:AVERAGE \ CDEF:real=vsim,$DAY,* \ CDEF:unrl=vunk,$DAY,* \ AREA:real#FF0000:"Number of spam messages" \ STACK:unrl#0000FF:"Number of false negatives" ## To prevent reading the gif while it's being written: mv -f tmpgraph.gif simgraph.gif date ## Sleep one more second. Note that the whole loop ## will take more, because it's relatively resource ## intensive. sleep 1 done -- Unsubscribe mailto:[EMAIL PROTECTED] Help mailto:[EMAIL PROTECTED] Archive http://www.ee.ethz.ch/~slist/rrd-users WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi