[rrd-users] Re: Data Source Type

Alex van den Bogaerdt alex at ergens.op.het.net
Wed Mar 5 01:20:02 MET 2003


On Tue, Mar 04, 2003 at 06:56:30PM -0500, Eric Ferguson wrote:

> I am curious how a DS of type COUNTER is determined to be 32bit or
> 64bit.  I know RRDTool has to understand the difference in order to take
> into account counter overflows, but I am just not sure how RRDTool
> differentiates this.  I am doing the typical InOctet / OutOctet graphing
> and just needed some clarification.

By black magic :)



Seriously, an overflow is when the new counter value is lower than the
previous counter value.  This means that the difference is negative.

The "real" difference should have been higher, by
a) 2^32
or
b) 2^64

Take this negative difference.  Add 2^32.  Still negative?  Wrong number
was added so subtract it and add the correct one: 2^64.

If the current counter value is "A" and the previous is "B":

    delta = A - B;
    
    if ( delta < 0 ) {
        delta += 2^32;
        if ( delta < 0 ) {
            delta -= 2^32;
            delta += 2^64;
        }
    }

The difference should be positive (or zero) by now.  


example:

A should have been 2^64 + 10
B is 2^64 - 10

diff = A - B = (2^64 + 10) - (2^64 - 10) = 20

however, due to the counter wrap:

diff = A - B = (10) - (2^64 - 10) = -(2^64) + 20

diff += 2^32    --> diff == -(2^64) + 2^32 + 20  --> still negative

diff -= 2^32    --> original diff retained

diff += 2^64    --> 2^64 - (2^64) + 20 = 20


HTH
Alex
-- 
Much of what looks like rudeness in hacker circles is not intended to give
offence. Rather, it's the product of the direct, cut-through-the-bullshit
communications style that is natural to people who are more concerned about
solving problems than making others feel warm and fuzzy.

http://www.tuxedo.org/~esr/faqs/smart-questions.html

--
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