Skip to content
Mar 21 / Greg

Monitor Bind With Cacti

If someone puts in a support ticket saying they are having DNS issues with your server, what do you do to quantify how your server is acting…? This is the “boat” I found myself in a while back. I decided to use cacti to poll my devices. I happen to run Bind9. I built off of a handy template I found on the Cacti forums. Though I did end up modifying it quite a bit. You can grab my version here: Cacti-Bind (3949 downloads) .


Install Steps

You can follow the Template steps, but I’ve got some tweaks specific for my Centos CactiEZ install.

Install SNMP on your DNS server

yum install net-snmp net-snmp-utils net-snmp-devel

Edit snmpd.conf [/etc/snmp/snmp.conf]
# Set new community string

com2sec notConfigUser  default       NewString

Allow your new string to view more of the snmp tree.

view    systemview    included   .

Add DNS query extend

# DNS query
extend . dnscache-stats /root/bin/

Restart snmp service

service snmpd restart

Be sure to set the SNMPD service to start on boot.

Edit your linux firewall to allow your cacti machine to access UDP port 161 on the DNS server.

Create the folder /var/cache/bind and make it writable.

Edit /etc/named.conf
Set “statistics-file “/var/named/data/named_stats.txt”;” to statistics-file “/var/cache/bind/named.stats”;

Reload your named service

service named restart

From the CLI issue “rndc stats”.

rndc stats

Ensure that the stats file is generated in /var/cache/bind. If it produces an RNDC warning[WARNING: key file (/etc/rndc.key) exists, but using default configuration file (/etc/rndc.conf)] you will need to:

  • Rename /etc/rndc.conf to anything else.
  • Edit named.conf and comment out the controls section.
  • Restart bind “service named restart”.
  • Copy the and files to the /root/bin folder and ensure they are executable.

    On Cacti Server

    Add the modified file(ensure it is executable) to the scripts folder.

    Import your cacti xml file.

    Live long and prosper.

    One Comment

    leave a comment
    1. Bob / Sep 23 2014

      Dear Greg,

      That was a BINGO for me!
      I’m in a great need for monitoring DNS’s, and also to find a way generating stats. What I was thinking for the stats that how can we have stats on hits per domain/IP? if possible..

      Kind regards,

    Leave a Comment