[SOLVED] Displaying Pi-Hole stats in Conky
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[SOLVED] Displaying Pi-Hole stats in Conky
Hello all,
Instead of having the web dashboard open all the time, I'd like to display the Pi-Hole stats via Conky. Is this possible? A quick search on the internet doesn't bring up any results other than https://www.reddit.com/r/pihole/comment ... ole_conky/ but it doesn't give me any code I can put into conky.conf
I'm actually surprised that nobody has done this before. The web dashboard is great but I don't want the browser open all the time, and I know I can use the CLI and display it like that, but again, I want it fixed into conky with the basic stats.
Any suggestions?
Instead of having the web dashboard open all the time, I'd like to display the Pi-Hole stats via Conky. Is this possible? A quick search on the internet doesn't bring up any results other than https://www.reddit.com/r/pihole/comment ... ole_conky/ but it doesn't give me any code I can put into conky.conf
I'm actually surprised that nobody has done this before. The web dashboard is great but I don't want the browser open all the time, and I know I can use the CLI and display it like that, but again, I want it fixed into conky with the basic stats.
Any suggestions?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Displaying Pi-Hole stats in Conky
In that link you show, there's a posted link to a deviantart solution, it is a conky config, in fact the one you are looking at.
Re: Displaying Pi-Hole stats in Conky
Yes, I originally clicked on it and I couldn't find where to download it, it sends you to deviantart. I just went there again and realised that I had to create a deviantart account in order to download the script. However, the script doesn't work.
Here is the script. I took it from that download and added it to my conky.conf file but it doesn't display the stats.
Code: Select all
DNS 1${alignr}${execi 1000 nmcli device show wlp3s0 | grep DNS | awk 'NR==1 {print $2}'}
DNS 2${alignr}${execi 1000 nmcli device show wlp3s0 | grep DNS | awk 'NR==2 {print $2}'}$font
#
${execi 60 curl pi.hole/admin/api.php | sed 's/.$//' > ~/.cache/pi.txt}${alignc}Pi-Hole stats:
${voffset 5}${exec awk -F '[:,]' '{print \
"DNS Queries Today: "$4"\n" \
"Queries Blocked: "$6"\n" \
"Total Domains Blocked: "$2"\n" \
"Queries Forwarded: "$12"\n" \
"Queries Cached: "$14"\n" \
"Unique Clients: "$16 }' ~/.cache/pi.txt
Re: Displaying Pi-Hole stats in Conky
pi.hole will be defined on your network if your machine is set to use that dns, so it will do the query and save the results locally and use that to populate the data in the next lines.
You are not doing anything admin-wise, so no login/password.
You should look at the first 2 lines where is says
You can check with the terminal command:
You are not doing anything admin-wise, so no login/password.
You should look at the first 2 lines where is says
wlp3s0
.You can check with the terminal command:
nmcli device status
to find some active device that you should be using in place of that wlp3s0
device name.Re: Displaying Pi-Hole stats in Conky
Yeah I figured that out, I changed that from "wlp3s0" to "enp3s0". It now displays the PiHole DNS and my router gateway, but none of the stats.
Re: Displaying Pi-Hole stats in Conky
you can run that on terminal to see any info:
curl pi.hole/admin/api.php
Re: Displaying Pi-Hole stats in Conky
That command didn't return a result:
Code: Select all
$ curl pi.hole/admin/api.php
curl: (6) Could not resolve host: pi.hole
Code: Select all
$ curl 192.168.1.192/admin/api.php
{"domains_being_blocked":93465,"dns_queries_today":18836,"ads_blocked_today":3290,"ads_percentage_today":17.466553,"unique_domains":1704,"queries_forwarded":10961,"queries_cached":4229,"clients_ever_seen":12,"unique_clients":10,"dns_queries_all_types":18836,"reply_NODATA":2764,"reply_NXDOMAIN":246,"reply_CNAME":8127,"reply_IP":7289,"privacy_level":0,"status":"enabled","gravity_last_updated":{"file_exists":true,"absolute":1634601633,"relative":{"days":2,"hours":21,"minutes":31}}}
Re: Displaying Pi-Hole stats in Conky
You changed the formatting around on the config and it broke it.
there's the original:
You need to be checking the line that says Queries Blocked, for accuracy, and mainly that last line, Unique Clients, you did something to change the total of the
there's the original:
Code: Select all
${execi 60 curl pi.hole/admin/api.php | sed 's/.$//' > ~/.cache/pi.txt}${alignc}Pi-Hole stats:
${voffset 5}${exec awk -F '[:,]' '{print \
"Domains Blocked: "$2"\n" \
"DNS Queries Today: "$4"\n" \
"Queries Blocked: "$6 " - (" int($8)"%)\n" \
"Queries Forwarded: "$12"\n" \
"Queries Cached: "$14"\n" \
"Unique Clients: "$16'} ~/.cache/pi.txt}
${exec}
command, and maybe it's making awk puke, but either way the exec is failing because of that quote mark.Re: Displaying Pi-Hole stats in Conky
That worked, thank you!
Re: [SOLVED] Displaying Pi-Hole stats in Conky
You are welcome!