Munin has plugins that allow us to get nice graphs of the DNS queries made to Unbound on the machine. However, they aren't working by default!
This tutorial assumes Munin and Unbound are already configured and working on your server.
I'm using Debian 8 and 9, but it should work on Ubuntu, and certainly most distributions.
Note: You can use my script if you want to install Unbound a local DNS resolver on your machine.
First, we need to enable unbound stats.
/etc/unbound/unbound.conf and add:
statistics-interval: 0 statistics-cumulative: no extended-statistics: yes python: remote-control: control-enable: yes
service unbound restart
Then, enable the munin plugins:
cd /etc/munin/plugins ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_by_class ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_by_flags ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_by_opcode ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_by_rcode ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_by_type ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_histogram ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_hits ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_memory ln -s /usr/share/munin/plugins/unbound_munin_ /etc/munin/plugins/unbound_munin_queue
/usr/share/munin/plugins/unbound_munin_ doesn't exist, that means you're running an old version of Unbound like 1.4.22 on Debian 8.
The solution is to download the source package and extract the plugin.
First, make sure your
/etc/apt/sources.list contains the
deb-src entries. If not, this one is needed:
deb http://deb.debian.org/debian jessie main
Then update your local repositories and download the Unbound packages:
apt update apt-get source unbound
Copy the Unbound plugin from the extracted package:
cp unbound-*/contrib/unbound_munin_ /usr/share/munin/plugins/
Finally, configure Munin for your Unbound installation. On Debian, add the following to
[unbound*] user root env.statefile /var/lib/munin-node/plugin-state/unbound-state env.unbound_conf /etc/unbound/unbound.conf env.unbound_control /usr/sbin/unbound-control
You can now test your plugins, for example:
[email protected] /e/m/plugins# munin-run unbound_munin_by_type n_q_t_A.value 16 n_q_t_PTR.value 12 n_q_t_AAAA.value 16
Restart munin-node, and you should see nice Unbound graphs appear on your web interface:
That seems easy, and it is, however finding documentation about this is awfully hard to find so I'm glad I can share it here.