I've created a script and set of templates to retrieve stats from a server running Bind 9.6.
These are loosely based on the methods in for Bind 9.5, but pretty much everything has changed to work with the new version and to make use of the extra statistics available. I use the scp method to avoid having to set up snmpd on your name servers. The bind 9.5 templates relied on the cacti server causing stats to be generated. This could lead to inconsistent stats depending on when the poller decided to run this script - it wouldn't be exactly 1 poller interval every time. In this version the name server itself must be setup to generate stats (instructions below).
There are 3 graphs, all display in queries or responses per second:
- Record type of incoming queries (server activity) Record type of outgoing queries (resolver activity) Response type of answered queries
1) Generate stats file
The most important part is to generate the stats file on your bind server.
The script expects that you will run 'rndc stats' once every cacti polling cycle, truncating or deleting the existing file not appending to it.
This is to keep the file small and lean as it is copied every poller cycle. By default bind appends to the stats file.
The easist way to do this is create a small shell script and put it in your name servers crontab. It need only have 3 lines really:
Code: Select all
#!/bin/sh
rm /var/named/stats/named.stats
rndc stats
The user running the cacti poller on your cacti server must be able to ssh (scp) to the name server and retrieve the stats file.
Cacti's poller can't respond to a password prompt so you must setup public key authentication. This is easier than it sounds as most ssh servers will be setup for this by default.
However you need to run 'ssh-keygen' on the cacti server as the poller user. Hit enter at each prompt for defaults.
Now append the contents of '/home/<cacti_poller_user>/.ssh/id_rsa.pub' to '/home/<remote_ssh_user>/.ssh/authorized_keys' on the name server. Careful of extra new lines in there!
Try logging in with 'ssh <name_server>'. There are some pitfalls to setting this up such as permissions of the authorized_keys file, but I won't detail everything here.
3) Install TCL
The script is TCL based, so you will need to install TCL 8.4+ if it's not part of your cacti server's distribution, e.g.
Code: Select all
yum install tcl
4) Test script
Test the script by running it manually under the same user as the cacti poller:
Code: Select all
tclsh /var/www/cacti/scripts/bind96-stats.tcl -h <name_server_ip> -u <remote_ssh_user> -r in
tclsh /var/www/cacti/scripts/bind96-stats.tcl -h <name_server_ip> -u <remote_ssh_user> -r out
tclsh /var/www/cacti/scripts/bind96-stats.tcl -h <name_server_ip> -u <remote_ssh_user> -r misc
5) Debug NANs
If some but not all lines in the graph legend show NANs the most likely cause is that your server is not returning stats for these items.
Say you see a NAN under outcoming HINFO queries.. Run the script manually and check there is some output for QUERIES_OUT_HINFO:
Code: Select all
tclsh /var/www/cacti/scripts/bind96-stats.tcl -h 10.203.22.28 -u netman -r out
TOTAL_QUERIES:12448274 TOTAL_NOTIFIES:7 TOTAL_UPDATES:147 QUERIES_OUT_A:3000925 QUERIES_OUT_CNAME:3918 QUERIES_OUT_SOA:1865 QUERIES_OUT_PTR:108987 QUERIES_OUT_MX:55196 QUERIES_OUT_TXT:774220 QUERIES_OUT_AFSDB:1 QUERIES_OUT_AAAA:1497841 QUERIES_OUT_SRV:10847 QUERIES_OUT_SPF:376 QUERIES_OUT_ANY:278
<fix>
Any comments/difficulties let me know.
0.2 - script update to handle multiple hosts better, minor graph updates.
cheers,
N