Last night I attempted to get named monitoring working with Munin on my two cPanel DNS Only boxes. Named is actually the most important service to monitor on a DNS Only box so in my opinion it should be enabled by default when you install Munin via WHM.
The whole process was actually really straightforward and the only thing I had to do was to apply a set of Debian instructions I found here, on CentOS. Here’s how you can install Munin and setup named monitoring
Install Munin via WHM
cPanel -> Manage Plugins -> Check “Install and keep updated” -> Save
Configure named
Login to you server via SSH, open /etc/named.conf
and add the following:
logging { /* If you want to enable debugging, eg. using the 'rndc trace' command, * named will try to write the 'named.run' file in the $directory (/var/named"). * By default, SELinux policy does not allow named to modify the /var/named" directory, * so put the default debug log file in data/ : */ channel default_debug { file "data/named.run"; severity dynamic; }; channel b_query { file "/var/log/bind9/query.log" versions 2 size 1m; print-time yes; severity info; }; category queries { b_query; }; };
Save the changes, and restart named
[root@dns1 ~]#/etc/init.d/named restart Stopping named: [ OK ] Starting named: [ OK ]
Configure the bind9 plugins
First you’ll have to create the symlinks to the two bind9 plugins:
ln -s /usr/share/munin/plugins/bind9 /etc/munin/plugins/bind9 ln -s /usr/share/munin/plugins/bind9_rndc /etc/munin/plugins/bind9_rndc
Now open the file /etc/munin/plugin-conf.d/cpanel.conf
and add the following code to the end of the file.
[bind9] user root env.logfile /var/log/bind9/query.log [bind9_rndc] user root env.querystats /var/named/data/named_stats.txt
Wrapping things up
Finally restart munin-node
, run rndc stats
and try munin-run bind9
& munin-run bind9_rndc
to see if you get proper output like this:
[root@dns1 ~]#/etc/init.d/munin-node restart Stopping Munin Node agents: [ OK ] Starting Munin Node: [ OK ] [root@dns1 ~]#rndc stats [root@dns1 ~]#munin-run bind9 query_A.value 55 query_AAAA.value 30 query_ANY.value 1 query_other.value 0 [root@dns1 ~]#munin-run bind9_rndc query_recursion.value 0 query_success.value 49 query_failure.value 0 query_nxrrset.value 23 query_referral.value 0 query_nxdomain.value 0
What you’ll get
After leaving it run for at least 30 minutes you’ll see something like this
(Optional) Errors you might encounter
If you receive the following error
[root@dns1 ~]# munin-run bind9 Died at /etc/munin/plugins/bind9 line 74.
you need to create the bind9.state file like this:
touch /var/lib/munin/plugin-state/bind9.state chown munin:munin /var/lib/munin/plugin-state/bind9.state chmod g+rw /var/lib/munin/plugin-state/bind9.state
and try running munin-run bind9
again.
I am getting the following while trying to run the first command:
#munin-run bind9
No such file or directory at /etc/munin/plugins/bind9 line 60.
I double checked the file is there and that it is symlinked, any ideas?
here is the fix just in case anyone bumps into this:
mkdir /var/log/bind9
chown named:named /var/log/bind9
Thanks diego 🙂
Although after adding the code to your /etc/named.conf and restarting bind, this directory should’ve been created automatically.
Hello! Does this still work for current version of cPanel?
Doesn’t look like it. The bind9 module isn’t in /etc/munin/plugins anymore..
ln -s ‘/usr/share/munin/plugins/bind9’ ‘/etc/munin/plugins/bind9’
ln -s ‘/usr/share/munin/plugins/bind9_rndc’ ‘/etc/munin/plugins/bind9_rndc’