Top list in command line


Thank you for making pi-hole!

Being able to see the list of most requested domains in the webinterface is nice, but it would be even better for my setup if I were able to get that list on the command line or in a text file. More specifically, I would like to generate a list of the top (maybe 50, maybe more) most requested domains of the last 24 hours and another list over the last 7 days.

Some background of what I am trying to do: Right now, my RPi is running both pi-hole and unbound. The latter acting as a proxy to enable DNS-over-TLS. Unfortunately this is very slow, which is why I forced unbounds cache time to 24 hours. To increase performance further my idea was to renew the cache of the most requested domains every night. That way, those domains would always be answered from cache and never had to be queried when a client is trying to access them. Maybe doing this every 24 hours is not enough and I will change it to every 6 hours, simultaneously lowering the cache time.

In short, what I am asking for is something like this:
# pihole --top-domains -n 4 -h 24 --show-count 2034 1972 1720 992

Is that already possible? If not, would you consider implementing it?


Take a look at the options in FTLDNS:

Can be done easily via sqlite


sqlite3 /etc/pihole/pihole-FTL.db "select domain, count(domain) from queries where timestamp>=strftime('%s','now')-86400 group by domain order by count(domain) desc Limit 4"


sqlite3 /etc/pihole/pihole-FTL.db "select domain, count(domain) from queries where timestamp>=strftime('%s','now')-604800 group by domain order by count(domain) desc Limit 4"