Remind me: Configuring BIND9 plugin for Munin on FreeBSD (and Linux)

I was attempting to get Munin working on a new FreeBSD machine, monitoring the rate of queries to a Bind9 DNS server. Every time I attempted ‘munin-run bind9’ I was presented with the same error:

2011/01/29-18:09:55 [3581] Error output from bind9: 2011/01/29-18:09:55 [3581]     Died at /usr/local/etc/munin/plugins/bind9 line 41. 2011/01/29-18:09:55 [3581] Service 'bind9' exited with status 2/0. 

Digging around in the Bind9 Munin plugin, line 41 complains about a state file that Munin uses. The plugin immediately tries to open the state file, without checking if the file is actually present. (TODO: Check to see what ramifications there are to just creating the file if it is not present.)

Line 41:

open(Q,"< $STATEFILE") or die; 

After digging around to figure out the plugin state directory (/var/munin/plugin-state, for those following along at home), I was back in business.

[root@dns1 ~]# cd /var/munin/plugin-state [root@dns1 /var/munin/plugin-state]# touch bind9.state [root@dns1 /var/munin/plugin-state]# chgrp munin bind9.state [root@dns1 /var/munin/plugin-state]# chmod g+rw bind9.state [root@dns1 /var/munin/plugin-state]# ls -al total 4 drwxrwxr-x  2 nobody  munin  512 Jan 29 18:13 . drwxr-xr-x  3 munin   munin  512 Jan 29 14:47 .. -rw-rw-r--  1 root    munin    0 Jan 29 18:13 bind9.state 

Relevant bind named.conf stanza for query logging:

logging { channel default_queries { file '/var/log/queries.log' versions 3 size 500k; severity info; print-severity yes; print-category yes; print-time yes; }; category queries { default_queries; }; }; 

With that, ‘munin-run bind9’ worked. I restarted the munin-node process and queries are now being graphed as expected.

[Update 2012-02-20: Getting this working on Ubuntu Server]

After banging my head against the wall trying to get this plugin working on Linux, dying on the same line (about the inability to find the state file), this is how I got it working.

Create the following file with the appropriate permissions.

root@grenache:/var/lib/munin/plugin-state# ls -al bind9.state  -rw-rw-r-- 1 nobody munin 22 2012-02-20 15:39 bind9.state 

And now, voila:

root@grenache:/var/lib/munin/plugin-state# munin-run bind9 query_PTR.value 25 query_A.value 109 query_AAAA.value 199 query_other.value 0