l13t / icinga2_check_pihole

Simple check for Pi-hole status
GNU General Public License v3.0
3 stars 6 forks source link

Pi-hole requires API token now #4

Open wopfel opened 1 year ago

wopfel commented 1 year ago

Hi, I've updated my Pi-hole today. After that, the check script doesn't work any longer.

The error shown is:

...
    if url_output["status"] != "enabled":
TypeError: list indices must be integers or slices, not str

There's no result when querying Pi-Hole, since there's no authentication. Access to some API endpoints requires authentication now. This is the official blog post: https://pi-hole.net/blog/2022/11/17/upcoming-changes-authentication-for-more-api-endpoints-required/#page-content

I only have a quick-and-dirty solution right now. I've hardcoded the token in the check script.

    token = "TOKEN-FROM-PI-HOLE"
    status_url = 'http://' + host + ('' if port == 80 else ":"+str(port)) + '/admin/api.php?summaryRaw&auth=' + token

This change happens in line 42: https://github.com/l13t/icinga2_check_pihole/blob/master/check_pihole.py#L42

I'll have a look if I can create a PR some time, passing the auth token as a parameter to the script.

Regards, Bernd

aSilentSniper commented 1 year ago

Added PR #5 to implement it with a argument