j...@acorntoolworks.com (J.T. Conklin) writes:
> The problem is that because HAVE_STRTOULL is defined, stat_t,
> STAT_MAX, PRI_STAT, and strtostat() are defined to be/use 64 bit 
> values, even though the network counters read from /proc/net/dev
> are 32 bits.  This means that a huge increment is added when the
> counter overflows.
>
> What's the way to fix this so it can be integrated into ganglia?
>
> It appears that these types/#defines are only used for network
> stats, so we could simply change the conditional used to select
> ullong vs. ulong from HAVE_STRTOULL to something else.  In fact,
> from the git history, it appears that these stats all used to be
> 32 bits wide until change made about a year ago.

I'm now testing a patch that uses unsigned long / 32 bit counters if
__i386__ is defined.

While this works for my situation, it's probably not sufficent, as
there are surely other Linux architectures that use 32 bit network
counters.

There is also the real possibility that a 32 bit x86 compiled gmond be
run on a 64 bit x86_64 system.  This suggests that the network counter
width needs to be determined at run time instead of at compile time.
As far as I know there is nothing in /proc/ that signals this, so a
heuristic like the following (untested) may be necessary.

    /* receive */
    rbi = strtostat(p, &p ,10);
    if ( rbi >= ns->rbi ) {
       l_bytes_in += rbi - ns->rbi;
    } else {
       debug_msg("update_ifdata(%s) - Overflow in rbi: %"PRI_STAT" -> 
%"PRI_STAT,caller,ns->rbi,rbi);
       if (ns->rbi > ULONG_MAX) {
           l_bytes_in += ULLONG_MAX - ns->rbi + rbi;
       } else {
           l_bytes_in += ULONG_MAX  - ns->rbi + rbi;
       }
    }
    ns->rbi = rbi;

Thoughts?

    --jtc

-- 
J.T. Conklin

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Ganglia-developers mailing list
Ganglia-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Reply via email to