regular statistics dumps getting out of sync

Peter Koch pk at DENIC.DE
Mon Aug 7 11:59:45 UTC 2006


The BIND8 like STATS in nsd are of great help, so I have a nameserver (2.3.3)
running with "-s 60" to dump those statistics every minute. The data is
read, processed and fed into rrdtool to provide some query graphs.

Now it turns out that every now and then an interval doesn't last 60 seconds
but 61 instead. This may happen since alarm() doesn't guarantee instant
delivery. It would be nice, though, if the alarm restart tried to resync
the interval.

Instead of 

#ifdef BIND8_STATS
          alarm(nsd.st.period);
#endif

I'd like to propose that nsd set the alarm to
	nsd->st.period - (time(NULL) - nsd->st.boot) % nsd->st.period
that is, the remaining time for a multiple of the "-s" interval.

Even better for rrdtool use, the first dump would occur on a predictable
boundary, e.g. for 60 second intervals it would be written on the first
full minute, so the initial value would read

	nsd->st.period - nsd->st.boot % nsd->st.period

There's still a potential race condition, of course. And you wouldn't want
to try "-s 1".

Opinions?

-Peter



More information about the nsd-users mailing list