Calculating queries per second (BIND 9)

Martin McCormick martin at dc.cis.okstate.edu
Fri May 18 16:47:50 UTC 2001


	This strategy seems to work very well.  I have been
experimenting with gathering and looking at named.stats in
exactly this manner at our site.  One can write a shell script or
a little C program to handle this task.  All you need to do is
store whatever counter you are interested in as a numerical
variable, take the current reading, and subtract your previous
reading from the current one to get
the number of successful queries or failures that occurred
between readings.

	The numerical field shown in the header

+++ Statistics Dump +++ (989269200)

	Is the unsigned long equivalent of the number of seconds
since Midnight UTC January 1, 1970.  If you wrote your data
mining engine in C, you can use the standard time handling
functions which can turn an unsigned long back in to a valid date
by

    struct tm *timeptr;

	Which sets up the template.  You then can isolate the
digits in the numerical part of the header and use sscanf on what
you got to convert that large number in to an unsigned long
which I called "mark" so you can stuff it in to the localtime
function.

    timeptr = localtime(&mark);
    printf("%s", asctime(timeptr));

	That will give you a string that looks much like what you
see when you issue the  date  command in UNIX.  The number I used
as an example translates to May 7 of this year at 16:00 in the
Central Daylight time zone.  The rest of you will see whatever
your local time was when the UTC clock had that same value.

	The only other thing you might want to do is be sure to
build your script or C program so that it "knows" the difference
between the first run and all others or you will see huge values
for the first set of readings.

	The initialization of all the counters and the rendering
of a human-readable date from the time stamp are the only
thought-provoking parts of the project.  My thanks to those who
were involved in development for making it relatively easy to get
and use this information.

Martin McCormick WB5AGZ  Stillwater, OK 
OSU Center for Computing and Information Services Data Communications Group

Andreas Gustafsson writes:
>While BIND 9 may not have all the bells and whistles of BIND 8 in the
>statistics department, it does at least have "rndc stats".  You could
>run "rndc stats" at regular intervals and look at how much the query
>counts in named.stats have increased each time.


More information about the bind-users mailing list