Add Unbound stats to PADD for Pi-Hole

Et cetera
2 min readJan 23, 2021

--

Since I’m using Unbound on the Pi-Hole, that will give you better privacy and performance for your DNS, I wanted to have some infos about what Unbound is and how it’s performing. So I decided to delete some not useful (for me) infos on PADD, and I replaced them with Unbound stats.

I wrote a simply tutorial of my setup, that I suggest you to read before going forward, you can find it here.

First of all you need to enable Unbound stats by editing

/etc/unbound/unbound.conf.d/pi-hole.conf

and add this text

# Remote control config section. remote-control: control-enable: yes

Then restart Unbound or the Pi-Hole and try to write this command to grab all the stats from Unbound:

sudo unbound-control stats_noreset

And it should give you some nice stats:

pi@pi-hole:~ $ sudo unbound-control stats_noresetthread0.num.queries=19067thread0.num.queries_ip_ratelimited=0thread0.num.cachehits=2379thread0.num.cachemiss=16688thread0.num.prefetch=490thread0.num.zero_ttl=0thread0.num.recursivereplies=16688thread0.requestlist.avg=0.489114thread0.requestlist.max=17thread0.requestlist.overwritten=0thread0.requestlist.exceeded=0thread0.requestlist.current.all=0thread0.requestlist.current.user=0thread0.recursion.time.avg=0.101366thread0.recursion.time.median=0.0540473thread0.tcpusage=0thread1.num.queries=18570thread1.num.queries_ip_ratelimited=0thread1.num.cachehits=2390thread1.num.cachemiss=16180thread1.num.prefetch=428thread1.num.zero_ttl=0thread1.num.recursivereplies=16180thread1.requestlist.avg=0.495063thread1.requestlist.max=19thread1.requestlist.overwritten=0thread1.requestlist.exceeded=0thread1.requestlist.current.all=0thread1.requestlist.current.user=0thread1.recursion.time.avg=0.100554thread1.recursion.time.median=0.0536302thread1.tcpusage=0thread2.num.queries=19002thread2.num.queries_ip_ratelimited=0thread2.num.cachehits=2336thread2.num.cachemiss=16666thread2.num.prefetch=459thread2.num.zero_ttl=0thread2.num.recursivereplies=16666thread2.requestlist.avg=0.504thread2.requestlist.max=25thread2.requestlist.overwritten=0thread2.requestlist.exceeded=0thread2.requestlist.current.all=0thread2.requestlist.current.user=0thread2.recursion.time.avg=0.101554thread2.recursion.time.median=0.0535782thread2.tcpusage=0thread3.num.queries=19157thread3.num.queries_ip_ratelimited=0thread3.num.cachehits=2445thread3.num.cachemiss=16712thread3.num.prefetch=482thread3.num.zero_ttl=0thread3.num.recursivereplies=16712thread3.requestlist.avg=0.491916thread3.requestlist.max=21thread3.requestlist.overwritten=0thread3.requestlist.exceeded=0thread3.requestlist.current.all=0thread3.requestlist.current.user=0thread3.recursion.time.avg=0.099270thread3.recursion.time.median=0.0538591thread3.tcpusage=0total.num.queries=75796total.num.queries_ip_ratelimited=0total.num.cachehits=9550total.num.cachemiss=66246total.num.prefetch=1859total.num.zero_ttl=0total.num.recursivereplies=66246total.requestlist.avg=0.495015total.requestlist.max=25total.requestlist.overwritten=0total.requestlist.exceeded=0total.requestlist.current.all=0total.requestlist.current.user=0total.recursion.time.avg=0.035852total.recursion.time.median=0.0537787total.tcpusage=0time.now=1611403433.310375time.up=132781.358234time.elapsed=132781.358234pi@pi-hole:~ $

But this are a bit hard to read, so I inserted it inside the PADD script to display these stats on the external display of the Raspberry PI, you can find the full script here. The text goes to /home/pi/padd.sh.

Restart the Pi-Hole and here you will find the Unbound stats under the Network section:

The total queries, well are the total DNS queries made to Unbound, the Missed are the queries not cached and Cached are… surprise: cached DNS queries =) The Reply is the average reply time that Unbound makes to reply to a query.

More precisely:

Total: number of queries received by thread
Reply: average time it took to answer queries that needed recursive processing. Note that queries that were answered from the cache are not in this average
Missed: number of queries that needed recursive processing
Cached: number of queries that were successfully answered using a cache lookup

If you have any suggestion to improve it, it’s welcome!

--

--

Et cetera
Et cetera

No responses yet