[rrd-users] Re: Plotting number of samples/values
Alex van den Bogaerdt
alex at ergens.op.HET.NET
Sat Jul 6 02:02:59 MEST 2002
Paschalis Tsiaras wrote:
> I am trying to plot a graph with 7 values only on the ds0 ( i.e 0,
> 100,200,300,400, 500,600).
> My question is quite simple ..
> How can print the percentages of each value in the bottom of the plot for a
> time period ?
> My plot look very good but I would like to print for example 0 : 3 %, 100 : 80
> % etc.
I'm not sure if I got the question right. Are you saying you only feed
rrdtool with the numbers 0,100,200,300,400,500,600 and 700 ?
If so: are you aware of normalizing? See the faq site if you aren't.
If you *are* aware and thus if you're certain you won't get unexpected
numbers, you could use CDEF instructions to do the trick.
Note: next is not tested. I never tried it so just try and follow
the reasoning. If I make a mistake somewhere, correct that mistake
and carry on.
First of all make sure the graph is correct. Use appropriate
start and end times. Appropriate is at exactly the right time,
for instance: 00:00 is correct while 00:01 is not. You need to
know *exactly* the amount of time covered in the graph.
Lets work with an image with width 400, covering 120000 seconds.
This results in 120000/400 seconds per pixel which is 300 seconds
or 5 minutes. This also assumes you have an RRA in that resolution.
Use CDEFs to remove all but one of the possible numbers.
1) fetch all values:
DEF:ds0=/path/to/database.rrd:ds0:AVERAGE
2) remove all numbers except 700:
CDEF:num700=ds0,700,EQ,400,*
this means: if (value_of_ds0 == 700) then return 400 else return 0
Suppose ds0 was 700 during only one of the intervals. The amount of
time it was this value is 300 seconds. During 300 out of the 120000
seconds, the rate therefore is 400 in the CDEF. The rate during the
other intervals is 0.
300 seconds at a rate of 400 per second makes a total of 120000.
When printing this total amount as an average, RRDtool will print "1".
This is exactly the amount of intervals where ds0 was 700.
Just one more: if the amount of intervals being equal to 700 was 3,
the calculations are: 300*3*400=360000. 360000/120000=3.
Do the same for
CDEF:num600=ds0,600,EQ,400,*
CDEF:num500=ds0,500,EQ,400,*
CDEF:num500=ds0,400,EQ,400,*
and so on.
Make sure to test the outcome. The result when added should match
the total number:
CDEF:total=num000,num100,num200,num300,num400,num500,num600,num700,+++++++
Printing is done so:
GPRINT:num000:AVERAGE:" 0: %3.0lf\n"
GPRINT:num100:AVERAGE:"100: %3.0lf\n"
and so on. Maybe you'd like to see fractions as well, use "%6.2lf"
If you want percentages, you should multiply by 100 and divide by the
total amount of intervals. This would mean adding ",100,*,400,/" to
each CDEF. However, that can be made more simple. The result of the
CDEF upto and including "EQ" is one or zero. The remainder would be
"400,*,100,*,400,/" which can be simplified into ",100,*". Each CDEF
would therefore become "CDEF:numxxx=ds0,xxx,EQ,100,*". This has a
nice side effect as well: the equasion doesn't use the width of the
graph anymore.
Let me know how it turned out. Perhaps you can produce a sample image
for the galery as well.
--
__________________________________________________________________
/ alex at slot.hollandcasino.nl alex at ergens.op.het.net \
| work private |
| My employer is capable of speaking therefore I speak only for myself |
+----------------------------------------------------------------------+
| Technical questions sent directly to me will be nuked. Use the list. |
+----------------------------------------------------------------------+
| http://faq.mrtg.org/ |
| http://rrdtool.eu.org --> tutorial |
+----------------------------------------------------------------------+
--
Unsubscribe mailto:rrd-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:rrd-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/rrd-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the rrd-users
mailing list