librenms/librenms-agent

pi-hole script not working with Pi-hole V5 API / fix attached

elherr opened this issue · 3 comments

?summaryRaw and ?getQueryTypes in Pi-hole V5 return more elements than script is written to process. I've attached updated script that works with V5. Also attached parsed JSON output from V5 API.

Changes:

$ diff pi-hole.orig pi-hole
68c68
< 	GET_STATS=$(curl -s $API_URL$URL_READ_ONLY | jq '.[]')
---
> 	GET_STATS=$(curl -s $API_URL$URL_READ_ONLY | jq '.[]' | head -n 7)
71c71
< 	GET_QUERY_TYPE=$(curl -s $API_URL$URL_QUERY_TYPE$API_AUTH_KEY | jq '.[][]')
---
> 	GET_QUERY_TYPE=$(curl -s $API_URL$URL_QUERY_TYPE$API_AUTH_KEY | jq '.[] | .["A (IPv4)","AAAA (IPv6)","PTR","SRV"]')

pihole_API_v5-output.txt
pi-hole_script_v5.txt

Bad output from original script is as follows --
$ ./pi-hole.orig
94821
155447
4469
2.874935
2543
29597
119801
41
41
155447
56
12
555
11417
0
"enabled"
{

"file_exists":
true,

"absolute":
1589710717,

"relative":
{

"days":
3,

"hours":
11,

"minutes":
10

}
}
94.94
2.93
0
1
0.01
1.1
0.01
0

I've just installed the latest pihole and it works fine for me, I got caught out by not installing jq (Think documentation should stat this is a dependency_

@t0m5k1
is this a package which should be installed to prevent problems?
If so, could you write a PR for LibreNMS Application documentation so others also know which package should be installed to use this agent.

Closing. Fixed by this --
#322