Cache / server statistics

The real status / efficency of the cache seems to be a hot topic in the discussions, due to optimizing the individual setup.

Prerequisite:

  • Setting log-queries=extra in the dnsmasq config

Trigger :

  • Call killall -s SIGUSR1 dnsmasq from shell

Output:

Dec 21 14:23:42 dnsmasq[15882]: time 484980
Dec 21 14:23:42 dnsmasq[15882]: cache size 1000000, 0/191 cache insertions re-used unexpired cache entries.
Dec 21 14:23:42 dnsmasq[15882]: queries forwarded 46, queries answered locally 22
Dec 21 14:23:42 dnsmasq[15882]: queries for authoritative zones 0
Dec 21 14:23:42 dnsmasq[15882]: server 156.154.70.1#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: server 129.250.35.250#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: server 4.2.2.1#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: server 8.8.4.4#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: server 8.8.8.8#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: server 176.95.16.251#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: server 176.95.16.235#53: queries sent 46, retried or failed 0
Dec 21 14:23:42 dnsmasq[15882]: Host                                     Address                        Flags      Expires
Dec 21 14:23:42 dnsmasq[15882]: www.bmbuildingpteltd.com       192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: heisseempfehlung8.de           192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: bigstars-08.com                192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: www.freeappandroid.info        192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: talented23-writer.xyz          192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: revengetalent.com              192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: hacking-for-beginners.blogspot 192.168.2.10                             4F I   H   0
Dec 21 14:23:42 dnsmasq[15882]: freefuckbookszandfa.ru;1       192.168.2.10                             4F I   H   0

Negogiate:

  • Output of host records might kill the webfrontend (php process) in my proof of concept. This should be avoided for the "inspect the tail log" feature.

Edit: I have realized that there is already some progress on utilizing the extra logging flag in github, but please consider the negogiation bullet.

which of these statistics would you like to see? Something like queries forwarded 46, queries answered locally 22 could always be reported by FTL without having to have dnsmasq report anything. I doubt that it is important how many domains are currently in dnsmasq's cache, as only the result (ration forwarded/cached) is of interest. This information is already made available in the Forward Destinations (integrated) graph (see local).

I have see serveral post where people were in doubt about their cache has been choosen to small. I also compiled the dnsmasq source to drop the cache limit. The actual status of the cache would be as nice as the load, or the mem consumption or the temperature. What do you think?

Hmm, okay. Is there any way of getting this information out of dnsmasq without having to fill the log file with tons of stuff by sending SIGUSR1?

You may double check it, but only displaying the log in the frontend is killing php. Maybe bypassing the host section for the log viewer could be an option or a button to poll the cache status ...

They would still go into dnsmasq's log, creating not only a major amount of writing to the disk (which e.g. flash drives don't like too much) but will surely also increase the log file size by several if not dozens of Megabytes each time you click on such a button

hmmmm ... a big mess for a few digits.

I have been reading the man page of dnsmasq a bit more in detail and it tells us:

The cache statistics are also available in the DNS as answers to queries of class CHAOS and type TXT in domain bind. The domain names are cachesize.bind, insertions.bind, evictions.bind, misses.bind, hits.bind, auth.bind and servers.bind. An example command to query this, using the dig utility would be

dig +short chaos txt cachesize.bind

Worth a try? I am writing from my cellphone,... but I will try when christmas activities going to become boring for me.

the proposed command nails it:

dig +short chaos txt cachesize.bind insertions.bind evictions.bind misses.bind hits.bind auth.bind servers.bind
"10000"
"11"
"0"
"17"
"14"
"0"
"156.154.70.1#53 17 0" "129.250.35.250#53 17 0" "4.2.2.1#53 17 0" "8.8.4.4#53 17 0" "8.8.8.8#53 17 0" "176.95.16.251#53 17 0" "176.95.16.235#53 17 8"

and without any modifications, the result is not interferring with the actual log. it's just ignored as request.

Okay, thanks for your research. At least this is a potential way to go!

If there will be some capacity left for a small feature like this, I would appreciate that.

I did some research on this and it seems quite non-trivial to get this without using some tool like dig... It would be cool to be able to add this inside FTL, but I don't see how to add this right now without having to include a custom library for CHAOS TXT type of queries.

1 Like

Implemented in v4.0

$ echo ">forward-dest" | nc 127.0.0.1 4711
-2 44.27 blocklist blocklist
-1 11.61 cache cache
0 24.40 208.67.220.220 resolver2.opendns.com
1 19.73 208.67.222.222 resolver1.opendns.com

https://docs.pi-hole.net/ftldns/telnet-api/