|Modification for Bind 9 graphing|
|Based upon DNS graph by Nathan Campi and modified for Bind 9.|
In his scripts for graphing DNS activity, Nathan is proposing a workaround for Bind 9.The need for a workaround arises because with Bind 8, the statistics kept by named used to include the number of queries received by the server for each type of query, it was easy to retreive the data from the statistics of named to draw the graph; whileBind 9 do not collect such data anymore, they should be collected by logging all the queries and calculating statistics.
Nathan proposes to log the queries to stderr and run named though a shell script; the script will read from stderr.
I don't like that solution because:
While at same time, named knows how to log the queries to a separate file and it includes builtin a mechanism to rotate the file when it reaches a certain size a Perl module like File::Tail knows how to read from a file that get rotated like syslog files or this named quey log file.
The solution I propose decribed bellow.
Configure Bind 9 to log all the queries to a file. In the example bellow, the file is called query-log, it rotates everytime the file grows over 1 MB and named keeps up to three backup versions of the file.
There will be up to four files created in named default directory, query-log, query-log.0, query-log.1 and query-log.2. The file that contains the most recent queries is query-log.
The following Perl script uses the module File::Tail to read the file event when it rotates, it computes the number of queries by type.
The script saves its own PID in the file $pidfile. Upon receiving a hang-up signal, it writes the statistics in the file $dumpfile. The $log_wait_interval is used by File::Tail to set the tick clock when the Perl script should become active and try to read new entries in the log file.
This script should loop indefinitely, it should be launch at boot time (use your prefered method to launch that script).
It corresponds to the script use for Bind 8 on Nathan's page. But to collect the statistics, it only has to send an hang-up signal to the script above and read the data from the file as designed in $dumpfile.
This script is called by SNMP in the exact way defined on Nathan's page for Bind 8.
The following modification has been suggested to me by Robert Jansen from Brussels University:
|Contact us: Olivier Nicole||Last update: Aug 2007|