Re: [cricket-users] Counter Overflows

From: Matt Zimmerman (mdz@csh.rit.edu)
Date: Mon Aug 23 1999 - 20:55:04 PDT


From: Matt Zimmerman <mdz@csh.rit.edu>

On Mon, Aug 23, 1999 at 11:22:25AM -0700, Doherty, Niall wrote:

> I'm attempting to graph a URLs/sec rate.
>
> The MIB on the cache is counting Total URLs served
> so far, and it is of type COUNTER.
>
> I've used a rrd-ds-type = COUNTER to retrieve the
> variable. RRD is correctly subtracting the current
> value from the previous value and dividing by the
> interval to give URLs/sec (averaged over the interval).
>
> However, when the counter rolls over to zero, I get
> a huge spike in my graph. I can see this coz I retrieve
> [...]

I had a similar problem when collecting a similar statistic (though not
via SNMP). The offending code (line 294 in rrd_update.c in RRDtool 1.0.6):

               /* simple overflow catcher sugestet by andres kroonmaa */
               /* this will fail terribly for non 32 or 64 bit ounters ... */
               /* are there any others in SNMP land ? */
               if (pdp_new[i] < (double)0.0 )
                   pdp_new[i] += (double)4294967296.0 ; /* 2^32 */
               if (pdp_new[i] < (double)0.0 )
                  pdp_new[i] += (double)18446744069414584320.0; /* 2^64-2^32 */;

This code attempts to correct for counter overflow by assuming that the counter
is either 32 or 64 bits. My workaround (read: whack) was to patch rrdtool to
instead disregard the sample (pdp) if the counter appeared to have rolled over.
My patch (against version 0.99.31, I haven't upgraded to 1.0.6 yet) is below.

It would be nice if this were a runtime option, but I haven't had time to work
that out. I have been using this patch since rrdtool 0.99.11 (February?)
without problems (other than one less data point per rollover period).

--- rrdtool-0.99.31/src/rrd_update.c Wed May 26 15:35:06 1999
+++ rrdtool-0.99.31+dropof/src/rrd_update.c Thu Jun 3 16:04:43 1999
@@ -290,6 +290,11 @@
                    if(rrd.pdp_prep[i].last_ds[0] != 'U'){
                        pdp_new[i]= rrd_diff(updvals[i+1],rrd.pdp_prep[i].last_d
s);
                        if(dst_idx == DST_COUNTER) {
+#ifdef DROP_OVERFLOW
+ if (pdp_new[i] < (double)0.0) {
+ pdp_new[i] = DNAN;
+ }
+#else
                                /* simple overflow catcher sugestet by andres kr
oonmaa */
                                /* this will fail terribly for non 32 or 64 bit
counters ... */
                                /* are there any others in SNMP land ? */
@@ -297,6 +302,7 @@
                                pdp_new[i] += (double)4294967296.0 ; /* 2^32 */
                            if (pdp_new[i] < (double)0.0 )
                                pdp_new[i] += (double)18446744069414584320.0; /*
 2^64-2^32 */;
+#endif /* !DROP_OVERFLOW */

-- 
 - Matt

--------------------------- ONElist Sponsor ----------------------------

Congratulations GENEVINCENT. Our latest ONElist of the week. For full story and to submit yours, go to <a href=" http://clickme.onelist.com/ad/ootw23 ">Click Here</a>

------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Mon Mar 06 2000 - 19:01:01 PST