[rrd-users] Re: Calculating percentages over time

Alex van den Bogaerdt alex at ergens.op.het.net
Fri Nov 1 23:15:00 MET 2002

On Fri, Nov 01, 2002 at 12:31:15PM -0500, tallen at csc.sctboces.org wrote:

> I have 9 customers.  I have a 14 Mb pipe to the internet.  Over a 24 hour 
> period, 2 of my customers averaged 0.33Mb/s.  The total (all 9 
> customers) average was 1.68 Mb/s.

So you're able to find out what the total consumed bandwidth is, and you're
able to find out which customer is responsible for which part.  Right?

Don't worry about GPRINT yet, I'm just referring to the CDEFs here.

Let's define some variables:

   cust1traffic    DEF   the amount of data sent by customer 1
   cust2traffic    DEF   ...                                 2
   ...                   ...                               ...
   cust9traffic    DEF   ...                                 9

   totaltraffic    CDEF  the sum of cust1traffic .. cust9traffic

   cust1percent    CDEF  cust1traffic / totaltraffic * 100
   cust2percent    CDEF  cust2traffic / totaltraffic * 100
   ...                   ...
   cust9percent    CDEF  cust9traffic / totaltraffic * 100

   totalpercent    CDEF  the sum of cust1percent .. cust9percent

> These are school districts so there is very little traffic at 
> night.  One of these 2 customers had some traffic at night.  This customer 
> shows 26.7% utilization.  The customer with no night time traffic shows 
> 17.0%.  Two very different results using the same bandwidth over the 
> same 24 hour period!  The CDEF 
> calculating the percentage is just cust Mbs divided by total Mbps.  The 
> answer I want to get is .33/1.68 or about 19.6%.

The average printed by GPRINT is basically the total amount of bytes
divided by the total amount of time.

The values computed by the CDEFs are what you're going to use.

Each element of the array is a rate (Bps) during a fixed amount of time.
You can look at this as an amount of bytes (the numerator) and an amount
of time (the denominator).  Because the denominator will be equal for
the various CDEFs, you can do arithmetics on the numerators.

You want to see the ratio of customer_1 vs. total_traffic.  You want to
see this as a percentage.  A percentage is (x/y)*100.  The CDEF will thus
be CDEF:cust1percent=cust1traffic,totaltraffic,100,/,*

Now GPRINT this value and it should be the value you seek.

Totaltraffic (calculated using a CDEF) should match the uplink.
Totalpercent (calculated using a CDEF) should be 100

Test this (I may be wrong!!!).  Is this what you need?

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