l13t / icinga2_check_pihole

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

Added argument for newly needed API token #5

Open aSilentSniper opened 1 year ago

aSilentSniper commented 1 year ago

I added the needed token to the script

wopfel commented 1 year ago

Hi @aSilentSniper, Thanks for mentioning my issue. I'll try your patch the next few days.

wopfel commented 1 year ago

I've tried your patched version. Works like a charm. Thanks!

wopfel commented 1 year ago

When pasting an empty, or wrong token, the check script crashes:

Traceback (most recent call last):
  File "/usr/local/bin/check_pihole.py", line 77, in <module>
    main()
  File "/usr/local/bin/check_pihole.py", line 64, in main
    if url_output["status"] != "enabled":
TypeError: list indices must be integers or slices, not str

Unfortunately, the Pihole API answers with a HTTP status code 200. So there's only checking for an empty result I think. Having my patch applied, the output is:

UNKNOWN: Empty result from Pihole. Wrong API token?

Maybe you wanna add this patch in this PR. check_pihole.py.patch

(Apologies if this is not the best method for sharing the patch.)

aSilentSniper commented 1 year ago

@wopfel Thanks for your Patch it is working and i added it to this PR