linuxserver / Heimdall-Apps

Apps for Heimdall
MIT License
299 stars 325 forks source link

Pi-Hole Enhanced app not pulling any data despite working API connection #629

Closed nightchrono closed 9 months ago

nightchrono commented 1 year ago

I have created a pi-hole enhanced app on a Heimdall instance running on apache2 on an Ubuntu 22.04 VM. I actually have two pi-holes, one running on a raspberry pi 4, and one running on a ubuntu VM.

I can test and verify the API token, but no statistics are shown in the dashboard. Capture Capture2

Cleared the cache, restarted Apache, reboot the whole server, and tried multiple browsers.

keriati commented 1 year ago

@nightchrono What version of pi hole and heimdall are you using?

nightchrono commented 1 year ago

@nightchrono What version of pi hole and heimdall are you using?

Heimdall 2.5.7 Pi-hole FTL 5.22

nightchrono commented 1 year ago

Sorry, this is probably what you were after:

PI-HOLE V5.16.2 FTL V5.22 WEB INTERFACE V5.19

Forgive the caps lock, was copy/pasting off the footer.

Nikto655 commented 1 year ago

Im having the same issue.

kennychan-git commented 1 year ago

solved. in the URL, use something like this http://10.0.0.1/admin/

nightchrono commented 1 year ago

In my initial screenshots I was using /admin in the URL. I also tried using just /admin without the API specific link and it also does not work

yebo29 commented 1 year ago

Having the same issue. I've tried all sorts of incantations with the URL for the api: api.php, just /admin, api.php?summaryRaw, etc and still nothing. Can confirm that I can reach the api endpoint and get data back from within the Heimdall docker container.

root@15748f5faa60:/# curl "http://piholehost:8888/admin/api.php?summaryRaw&auth=<TOKEN>"
{"domains_being_blocked":503439,"dns_queries_today":6145, [...]
ChrLau commented 1 year ago

Do the logs from the PHP Laravel Framework log something? Should be under /path/to/your-heimdall-folder/storage/logs

nightchrono commented 1 year ago

Do the logs from the PHP Laravel Framework log something? Should be under /path/to/your-heimdall-folder/storage/logs

I see lots of errors in the log, but I don't know what any of them mean or what you would be looking for.

Want me to upload the log? I did a quick glance and didn't see my API key in it so I don't think there is anything sensitive in there.

ChrLau commented 1 year ago

I don't think the whole logfile is necessary. Can you execute the following grep command on the most recent logfile? grep local.ERROR laravel-2023-MM-DD.log (Replace MM and DD accordingly.)

That should show the first line of all error messages. You can then post them here. (Just one per type. We don't need the same error posted 100 times. ;-) )

And another quick question: Did you try entering http://ip.of.your.pihole/admin/ as the URL and leave the the URL field at the bottom (where you enter the API-Key) empty? That's how I have it configured and it works.

nightchrono commented 1 year ago

[2023-10-30 17:46:34] local.ERROR: Undefined property: stdClass::$ads_blocked_today {"exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$ads_blocked_today at /opt/heimdall/app/SupportedApps/Pihole/Pihole.php:33) [2023-10-30 17:46:34] local.ERROR: Undefined variable $ads_blocked_today (View: /opt/heimdall/app/SupportedApps/Pihole/livestats.blade.php) {"view":{"view":"/opt/heimdall/app/SupportedApps/Pihole/livestats.blade.php","data":{"errors":"<pre class=sf-dump id=sf-dump-1369121488 data-indent-pad=\" \">Illuminate\Support\ViewErrorBag {#1328 [2023-10-30 18:39:53] local.ERROR: Undefined variable $ads_blocked_today (View: /opt/heimdall/app/SupportedApps/Pihole/livestats.blade.php) {"view":{"view":"/opt/heimdall/app/SupportedApps/Pihole/livestats.blade.php","data":{"errors":"<pre class=sf-dump id=sf-dump-978453690 data-indent-pad=\" \">Illuminate\Support\ViewErrorBag {#1328 [2023-10-30 18:39:53] local.ERROR: Undefined property: stdClass::$ads_blocked_today {"exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$ads_blocked_today at /opt/heimdall/app/SupportedApps/Pihole/Pihole.php:33) [2023-10-30 20:56:50] local.ERROR: Undefined property: stdClass::$ads_blocked_today {"exception":"[object] (ErrorException(code: 0): Undefined property: stdClass::$ads_blocked_today at /opt/heimdall/app/SupportedApps/Pihole/Pihole.php:33) [2023-10-30 20:56:50] local.ERROR: Undefined variable $ads_blocked_today (View: /opt/heimdall/app/SupportedApps/Pihole/livestats.blade.php) {"view":{"view":"/opt/heimdall/app/SupportedApps/Pihole/livestats.blade.php","data":{"errors":"<pre class=sf-dump id=sf-dump-1147886275 data-indent-pad=\" \">Illuminate\Support\ViewErrorBag {#1328

Just changed the URL as suggested and it did not have any effect. Still not pulling data.

ChrLau commented 1 year ago

Ok, the variable stdClass::$ads_blocked_today gets it's value from the details variable. The details variable contains all data Heimdall received from the Pihole-API. But it decodes that data via json first. See line 27: https://github.com/linuxserver/Heimdall-Apps/blob/master/Pihole/Pihole.php#L27

Which Linux distribution are you running? Is the PHP JSON extension installed?

nightchrono commented 1 year ago

Two of them are ubuntu and one of them is raspbian

Php json was already installed when I tried on each machine to run "sudo apt-get install -y php-json"

EDIT

Ubuntu 22.04.3 and Raspbian 5.10.103-v71

ChrLau commented 1 year ago

Wait.. 3 hosts? Does that mean you have Pihole installed on all of them and the same problem on all of them? Is Heimdall able to reach all 3 of them? Do you use a separate API-Key for each Pihole instance?

Do you get a result when you execute the following command? (Replace with our API-Key) curl "http://ip.of.your.pihole/admin/api.php?summaryRaw&auth=<TOKEN>"

nightchrono commented 1 year ago

Wait.. 3 hosts? Does that mean you have Pihole installed on all of them and the same problem on all of them? Is Heimdall able to reach all 3 of them? Do you use a separate API-Key for each Pihole instance?

Do you get a result when you execute the following command? (Replace with our API-Key) curl "http://ip.of.your.pihole/admin/api.php?summaryRaw&auth=<TOKEN>"

Yeah, when I first opened the issue I had two pi-holes, now I have three and I have the same issue on each. I did say I had two in my opening comment.

I am using their unique API key on each, and Heimdall says it can talk to them when I test, but nothing is pulled on the dashboard.

When I run the command you posted I get:

"{"domains_being_blocked":151352,"dns_queries_today":29508,"ads_blocked_today":9988,"ads_percentage_today":33.84845,"unique_domains":2303,"queries_forwarded":12938,"queries_cached":6288,"clients_ever_seen":18,"unique_clients":18,"dns_queries_all_types":29508,"reply_UNKNOWN":291,"reply_NODATA":1475,"reply_NXDOMAIN":5195,"reply_CNAME":6511,"reply_IP":15996,"reply_DOMAIN":0,"reply_RRNAME":0,"reply_SERVFAIL":5,"reply_REFUSED":0,"reply_NOTIMP":0,"reply_OTHER":0,"reply_DNSSEC":0,"reply_NONE":0,"reply_BLOB":35,"dns_queries_all_replies":29508,"privacy_level":0,"status":"enabled","gravity_last_updated":{"file_exists":true,"absolute":1699175222,"relative":{"days":1,"hours":3,"minutes":54}}}"

I only ran the command against one of them. I can do the other two if you think it will help.

mvdkleijn commented 9 months ago

According to the code, setting:

  1. Your config URL to: http://ip.of.your.pihole/admin/ (last slash required)
  2. Your auth token to whatever is needed

Should work fine. The app should be adding this in between url and token: api.php?summaryRaw&auth=

mvdkleijn commented 9 months ago

Closing this to clean up, feel free to reopen or comment when needed.

Reasoning:

yebo29 commented 8 months ago

Having the same issue. I've tried all sorts of incantations with the URL for the api: api.php, just /admin, api.php?summaryRaw, etc and still nothing. Can confirm that I can reach the api endpoint and get data back from within the Heimdall docker container.

root@15748f5faa60:/# curl "http://piholehost:8888/admin/api.php?summaryRaw&auth=<TOKEN>"
{"domains_being_blocked":503439,"dns_queries_today":6145, [...]

Just want to say that this was a MAJOR user-error on my part. I didn't notice that integration was disabled. All I had to do is enable the config and it worked. Whoops.