librenms / librenms-agent

LibreNMS Agent & Scripts
GNU General Public License v2.0
118 stars 188 forks source link

Fix missing compatibility to Pi-hole V5 API (minimal changes) #322

Closed efelon closed 4 years ago

efelon commented 4 years ago

To minimize the impact of future API changes in terms of data order or additional data being appended, required elements are selected directly with the "jq" tool in the expected order.

In theory this change should be backwards compatible to the previous version of the Pi-hole API, but I don't have access to an older version (V4 API) to test it.

SourceDoctor commented 4 years ago

is it maybe possible to get the API Version which is used and then switch command for it to ensure old versions stay functional?

elherr commented 4 years ago

Thanks for updating the script! Added changes from master and your commit on my system with Pi-hole 5.1 (latest) and works well. Current API is version 3. $ curl -s http://localhost/admin/api.php/?version | jq { "version": 3 }

efelon commented 4 years ago

@SourceDoctor I think it should also work with the previous version of the API. But, as I wrote in the PR, I don't have a Pi-hole 4 installation around. Someone confirming my assumption would be really great.

And then of course if it is not working I can add a API version check as suggested by @elherr.

elherr commented 4 years ago

@efelon I'd hope no one with LibreNMS installed is using the old Pi-hole API at this point. If they are using old version of Pi-hole, I would have to guess they are not actively updating LibreNMS either.