[rrd-users] Re: ok...I drank a lot last nite

Alex van den Bogaerdt alex at ergens.op.HET.NET
Tue Jul 23 23:25:40 MEST 2002


Isaac wrote:

> I know I am taking samples every five minutes but what is the math to get
> the total of bits moved?

How is an average rate per second calculated:

Take a counter value at time "t1".  Let's call this value "v1".
Take another one at time "t2". Let's call this value "v2".

The counter increase is "v2 - v1".  This happened during the
time interval "t2 - t1".

The calculation is "rate = (v2 - v1) / (t2 - t1)".  The differences
are also known as deltas.  Write "rate = Dv / Dt"

Now you are querying the RRD.  You let RRDtool calculate the average
rate during a certain time interval.  The interval which you are
showing is "Dt".  RRDtool is programmed so that you can do this.
Also, you're getting the rate from RRDtool.  So, in the formula you
know "rate" and you know "Dt", now you can calculate "Dv" by shifting
"Dt" to the other end of the equal sign:  "rate * Dt = Dv".
The "Dv" value is the increase of the counter during the "Dt" time
interval.

But now you have a problem.  With the current release of RRDtool you
cannot use this average rate and do calculations on it.  There is a
workaround.  If all rates during an interval are multiplied by a
constant, the average will be multiplied by that same constant.  So,
if you make a CDEF that multiplies by the right amount of "t", the
average will also be multiplied by "t" and the average shown will be
"rate * Dt".  This is exactly what you want.

So:

Make sure to *know* the exact start and end time of the part of the
database you're going to show.  If you're going to use the 300-second
RRA to build the image, make sure both start and end times are exact
multiples of 300 seconds.  If you're going to use the 30-minute RRA,
start and end should be multiples of 1800.  You will have to know
which RRA is going to be used and for this you have to know how
RRDtool works.  See the tutorial if necessary, also see the FAQ.

So far you know "--start s" and "--end e".  You therefore know "Dt".

Remember:  Dv = rate * Dt.  You know how to get "rate", it can be
printed using GPRINT.  You want to print "rate*Dt" so you need to
multiply the average rate by "Dt".

average(r1,r2,r3,....rn)*Dt == average(r1*Dt, r2*Dt, r3*Dt... rn*Dt).

Use a CDEF to transform (r1,r2...rn) into (r1*Dt, r2*Dt...rn*Dt).

Fill in the blanks yourself from your own scripts.  Variable TIMESPAN
should be set by the calling script
   rrdtool graph ..... --end "20020723 00:00" --start end-$TIMESPAN
   DEF:rate=.....
   CDEF:amount=rate,$TIMESPAN,*
   GPRINT:amount:AVERAGE:"Total: %12.2lf B\n"

HTH
-- 
   __________________________________________________________________
 / 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