Monitoring DNS BIND with Zabbix
Shockingly enough out of the box Zabbix (version 6) does not include any template
to monitor a very crucial compontent every organization: DNS.
Like most open source aficionado my DNS of choice is BIND named
.
Luckily Zabbix has a pretty huge community and plenty of templates for it are
freely available, a quick search on the interwebz lead me to this
page.
Kudos to whoever wrote this template, I just took it and tweaked it a little bit.
BIND named configuration
named
needs to have statistics-channels
enabled:
$ less /etc/bind/named.conf.options
...
statistics-channels {
inet 127.0.0.1 port 8080 allow {
127.0.0.1;
};
};
...
Also make sure to enable zone-statistics
for the zones for which we would
like to gather statistics:
less /etc/bind/named.conf.local
...
zone "..." {
...
zone-statistics yes;
...
};
...
Zabbix Agent2 configuration
Now that we have told named
to expose statistics we need to instruct
Zabbix Agent2 (or legacy Zabbix Agent) to pick them up:
$ apt install xml2 curl -y
$ cat /etc/zabbix/zabbix_agent2.d/bind.conf
---
UserParameter=bind.net.udp,netstat -nua | grep :53 | wc -l
UserParameter=bind.net.tcp,netstat -nta | grep :53 | wc -l
UserParameter=bind.queries.in[*],curl http://127.0.0.1:8080/ 2>/dev/null | xml2 | grep -A1 "/statistics/server/counters/counter/@name=$1$" | tail -1 | cut -d= -f2
UserParameter=bind.queries.out[*],curl http://127.0.0.1:8080/ 2>/dev/null | xml2 | grep -A1 "/statistics/views/view/counters/counter/@name=$1$" | tail -1 | cut -d= -f2
UserParameter=bind.queries.query[*],curl http://127.0.0.1:8080/ 2>/dev/null | xml2 | grep -A1 "/statistics/server/counters/counter/@name=Qry$1$" | tail -1 | cut -d= -f2
---
$ systemctl restart zabbix-agent2
Zabbix Server configuration
Finally we need to import the template into Zabbix Server (version 6 LTS in my
case).
Login into Zabbix WEB UI, navitage Configuration
-> Templates
and click
the Import
button on the top right of the page.
Download the template file
and import it.
Last thing left to do is enable the template DNS-bind
on all DNS hosts in
Zabbix Server.
After a few seconds data should start to show up in Zabbix.