----- Original Message ---- > From: "Escobio, Roger " <[EMAIL PROTECTED]> > To: Bernard Li <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED] > Sent: Wednesday, September 10, 2008 9:19:47 PM > Subject: Re: [Ganglia-general] Anyone experience petabyte peaks in network > metric in ganglia 3.x.y ? > > > > > -----Original Message----- > > From: Bernard Li [mailto:[EMAIL PROTECTED] > > Sent: September 10, 2008 3:05 PM > > To: Escobio, Roger [CMB-IT] > > Cc: [EMAIL PROTECTED] > > Subject: Re: [Ganglia-general] Anyone experience petabyte > > peaks in network metric in ganglia 3.x.y ? > > > > Hi Roger: > > > > On Wed, Sep 10, 2008 at 11:52 AM, Martin Knoblauch > > wrote: > > > > >> I created a patch again linux/metrics.c (3.1.1 version) to add the > > >> counterdiff function found in *bsd/metrics.c > > >> Are you interested in it? Just let me know and I'll send > > it to the list > > >> > > > > > > Yes please. I am definitely like to have a look at your patch. > > > > In case the patch is too large to be sent to the mailing-list, you > > could also file a bug and upload the patch via bugzilla.ganglia.info. > > Well, is not big > As I said, it is just a copy paste from *bsd code , so not big deal :-) > > But at least compile and not coredump gmond in our linux :-) > Roger, [changed Mailing List to ganglia-developers]
just to understand things right, your patch is only a code cleanup and you still need the "#ifdef REMOVE_BOGUS_SPIKES" to get rid of the spikes. Correct? Some comments on the patch: >--- libmetrics/linux/metrics.c-ori 2008-09-09 18:54:40.000000000 +0000 >+++ libmetrics/linux/metrics.c 2008-09-09 19:09:44.000000000 +0000 >@@ -222,40 +222,20 @@ > if ( !ns ) return; > > rbi = strtoul( p, &p ,10); >- if ( rbi >= ns->rbi ) { >- l_bytes_in += rbi - ns->rbi; >- } else { >- debug_msg("update_ifdata(%s) - Overflow in rbi: %lu -> >%lu",caller,ns->rbi,rbi); >- l_bytes_in += ULONG_MAX - ns->rbi + rbi; >- } >+ l_bytes_in = counterdiff(rbi,ns->rbi,ULONG_MAX, 0); Shouldn't that be "+= counterdiff/..."? l_bytes_in is cummulated over all NICs. > ns->rbi = rbi; > > rpi = strtoul( p, &p ,10); >- if ( rpi >= ns->rpi ) { >- l_pkts_in += rpi - ns->rpi; >- } else { >- debug_msg("updata_ifdata(%s) - Overflow in rpi: %lu -> >%lu",caller,ns->rpi,rpi); >- l_pkts_in += ULONG_MAX - ns->rpi + rpi; >- } >+ l_pkts_in = counterdiff(rpi,ns->rpi,ULONG_MAX, 0); ditto > ns->rpi = rpi; > > for (i = 0; i < 6; i++) strtol(p, &p, 10); > rbo = strtoul( p, &p ,10); >- if ( rbo >= ns->rbo ) { >- l_bytes_out += rbo - ns->rbo; >- } else { >- debug_msg("update_ifdata(%s) - Overflow in rbo: %lu -> >%lu",caller,ns->rbo,rbo); >- l_bytes_out += ULONG_MAX - ns->rbo + rbo; >- } >+ l_bytes_out = counterdiff(rbo,ns->rbo,ULONG_MAX, 0); ditto > ns->rbo = rbo; > > rpo = strtoul( p, &p ,10); >- if ( rpo >= ns->rpo ) { >- l_pkts_out += rpo - ns->rpo; >- } else { >- debug_msg("update_ifdata(%s) - Overflow in rpo: %lu -> >%lu",caller,ns->rpo,rpo); >- l_pkts_out += ULONG_MAX - ns->rpo + rpo; >- } >+ l_pkts_out = counterdiff(rpo,ns->rpo,ULONG_MAX, 0); ditto > ns->rpo = rpo; > } > p = index (p, '\n') + 1; // skips a line >@@ -1305,3 +1285,40 @@ > val.f = most_full; > return val; > } >+ >+static unsigned long >+counterdiff(unsigned long oldval, unsigned long newval, unsigned long maxval, >unsigned long maxdiff) >+{ >+ unsigned long diff; >+ >+ if (maxdiff == 0) >+ maxdiff = maxval; >+ >+ /* Paranoia */ >+ if (oldval > maxval || newval > maxval) >+ return 0; Really cannot happen with maxval being ULONG_MAX. Even the paranoid should feel safe here :-) >+ >+ /* >+ * Tackle the easy case. Don't worry about maxdiff here because >+ * we're SOL if it happens (i.e. assuming a reset just makes >+ * matters worse).This >+ */ >+ if (oldval <= newval) >+ return (newval - oldval); >+ >+ /* >+ * Now the tricky part. If we assume counters never get reset, >+ * this is easy. Unfortunaly, they do get reset on some >+ * systems, so we need to try and deal with that. Our huristic >+ * is that if out difference is greater then maxdiff and newval >+ * is less or equal to maxdiff, then we've probably been reset >+ * rather then actually wrapping. Obviously, you need to be >+ * careful to poll often enough that you won't exceed maxdiff or >+ * you will get undersized numbers when you do wrap. >+ */ >+ diff = maxval - oldval + newval; >+ if (diff > maxdiff && newval <= maxdiff) >+ return newval; "diff > maxdiff" cannot happen, as maxdiff is ULONG_MAX >+ >+ return diff; >+} Otherwise one could accept the patch, because it reduces code-duplication. Cheers Martin ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Ganglia-developers mailing list Ganglia-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ganglia-developers