Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pi-hole dashboard shows zero except for domains blocked #191

Closed
jacobsalmela opened this issue Jan 18, 2016 · 75 comments
Closed

Pi-hole dashboard shows zero except for domains blocked #191

jacobsalmela opened this issue Jan 18, 2016 · 75 comments
Labels
Bug: Confirmed Verified as a bug to be resolved Help Wanted

Comments

@jacobsalmela
Copy link
Contributor

I haven't been able to replicate this, but I have had about five people say their dashboard shows zeroes, even though tail -f /var/log/pihole.log shows that queries are working and getting blocked. Please let me know if this is happening to you.

@jacobsalmela jacobsalmela added Bug: Confirmed Verified as a bug to be resolved Help Wanted labels Jan 18, 2016
@PromoFaux
Copy link
Member

image

Interestingly, I've had this issue with the dashboard since running the uninstall script. Not sure if the uninstall script is meant for general consumption, I've not actually looked into it yet, but may be part of the same issue. If not, I'll open a new one!

@PromoFaux
Copy link
Member

As an aside, the API appears to return the correct numbers:

image

@dschaper
Copy link
Member

Hmm... I get the same behavior, uninstall then reinstall and admin page looks the same as yours...

@PromoFaux
Copy link
Member

Found it! You can blame me for it, too..

https://github.com/jacobsalmela/AdminLTE/blob/master/index.php#L2

The file it's looking for does not exist, since I changed the files when I made the whitelisting changes (there was no need for pihole.2.light.txt since whitelisting is now directly done on gravity.list

Interestingly, api.php on the website get's it's number from the gravity list
https://github.com/jacobsalmela/AdminLTE/blob/master/api.php#L2

simplist fix is to change index.php to print the line count of gravity.list I'll create an issue over there

pi-hole/web#11 (comment)

@dschaper
Copy link
Member

Would it be hard to implement the API as a json file, and then have that available for calls, so the Admin page would populate from the json files? (Thinking about other things that are possible with a JSON API...)

@PromoFaux
Copy link
Member

Submitted a pull for AdminLTE that should fix it. Not tested as I'm not set up at work to try it out.

The ultimate goal should be that index.php makes a call to api.php, so that there is only one block of code to edit if anything changes. I've dealt with JSON packets in jquery before, though I have 0 experience in PHP!

@dschaper
Copy link
Member

I was just thinking that with JSON it would be extensible. We could redo the chronometer to pull from the JSON file for display and allow for more types of displays...

@PromoFaux
Copy link
Member

Might as well keep it in api.php, from a brief google, it shouldn't be too hard to consume the api from a bash script. That way, the JSON response is generated on demand, rather than on a schedule.

My next "when I'm bored" project is to get it working on my keyboard display!

@dschaper
Copy link
Member

You're thinking what I was thinking, except I was thinking more of a 16x2 LCD...

@PromoFaux
Copy link
Member

fixed:
image

@PromoFaux
Copy link
Member

Would it be hard to implement the API as a json file, and then have that available for calls, so the Admin page would populate from the json files? (Thinking about other things that are possible with a JSON API...)

@dschaper I'm working on a script tonight that outputs exactly the same as api.php but with the added advantage that it can be a)more extensible without having to update many web pages, b) Be a bit more intelligent when it comes to working out the total number of domains blocked as @Mcat12 mentions here C)Is a fresh JSON each time the script is run, as opposed to being a flat file generated on a schedule

@dschaper
Copy link
Member

I look forward to your changes and the PR's. How are you doing with learning Git? If you can, I highly suggest getting a trial account with Lynda.Com and doing the Git Essentials Training, it's a very good course that covers both Git and GitHub. It starts a little dry but covers a ton of essentials!

@PromoFaux
Copy link
Member

I'm learning by trial and error, I find it much more effective than watching a video! Like, if I have a history of the mistakes I've made I can see where I've gone wrong and not make them again. I'm sure it gives others a bit of a giggle, too. :)

You guys have been well humored about my messy commits, I'm sure others may not be! But they are getting better!

@dschaper
Copy link
Member

They are indeed getting better. The thing I like about Lynda is that it's not just watching videos. You actually set up a Git Repo and run all the commands and test on your workstation. So it's like a tutor giving you tips, but you do the work. (I guess you could just watch the videos but you wouldn't get much out of the course.) GitHub has a training course too. And then there is http://gitimmersion.com/

@PromoFaux
Copy link
Member

see #193 .

Some cleverness will need to be done with the website to consume this.

@dschaper
Copy link
Member

Are you up to the cleverness challenge? (I'm just a beginner with html and front end design work...)

@PromoFaux
Copy link
Member

@jacobsalmela
Copy link
Contributor Author

Fixed by AdminLTE #15

@DonLexos
Copy link

Just did a full new installation and even ran the updateDashboard.sh but the bug still seems to occur on a fresh installation. Is the fix pushed to live yet?

As an update, the API also does not know the correct numbers
{"domains_being_blocked":"68396","dns_queries_today":"0","ads_blocked_today":"6","ads_percentage_today":""}

@PromoFaux
Copy link
Member

Could you please run chronometer.sh -j and tell me the output? Thanks

also your index.php and api.php should match this and this respectively.

You can find the two web pages under /var/www/html/admin/

@DonLexos
Copy link

Sure! Step 1:

pi@pi-hole:/usr/local/bin $ chronometer.sh -j
Runtime error (func=(main), adr=11): Divide by zero
{"domains_being_blocked":"68396","dns_queries_today":"0","ads_blocked_today":"6","ads_percentage_today":""}

Checking for the 2 files, will update in a sec

@DonLexos
Copy link

Both files matched. To be 100% sure I swapped the linked copy with the one in the /admin/ folder to be sure, that did not help.

@DonLexos
Copy link

I do see that /var/log/pihole.log (which is populated) is owned by dnsmasq, not sure if that has always been the case in previous installations.

@PromoFaux
Copy link
Member

Runtime error (func=(main), adr=11): Divide by zero

OK, A slight oversight on my part there in percentage calculation, as I'm not checking for dns_queries_today being 0. (calculation is ads_blocked_today / dns_queries_today * 100)

That explains why your percentage is blank, but that doesn't effect anything else.

What it doesn't explain though is why dns_queries_today figure is 0, yet ads_blocked_today is 6

I've just run a fresh install myself and it's working fine..

I do see that /var/log/pihole.log (which is populated) is owned by dnsmasq

I'll check mine. Is there anything in your pihole.log?

@dschaper
Copy link
Member

I haven't tried the script, I just sudo rm -r /etc/pihole /var/www/html/pihole/ /var/log/pihole.log

@DonLexos
Copy link

pi@pi-hole:/usr/local/bin $ updateDashboard.sh
Already up-to-date.

@dschaper
Copy link
Member

capture

@PromoFaux
Copy link
Member

don't forget /var/www/html/admin

@dschaper
Copy link
Member

Ah, thanks, missing that one.

@PromoFaux
Copy link
Member

also, does your /var/www/html/admin/api.php or /var/www/html/admin/index.php match the master?

@dschaper
Copy link
Member

Getting a cup of coffee... Engaging brain...

@PromoFaux
Copy link
Member

This is what I get after running the uninstall script and clearing down '/var/www/html/'

image

(and then installing again.. obviously)

@PromoFaux
Copy link
Member

Getting a cup of coffee... Engaging brain...

I've stayed an hour and a half later at work than I should have... whoops! I'll give it some thought on the drive home

@dschaper
Copy link
Member

Okay, my admin is working now...

@PromoFaux
Copy link
Member

Excellent...! as for the root ownership stuff, that wasn't an issue before, so something has changed somewhere.. perhaps @jacobsalmela can point us in the right direction.

More to the point though, what is @DonLexos doing differently from us? If our Admin pages are working and the chrono -j output isn't falling over.....

This is new:

pi@raspberrypi:/etc/pihole $ whitelist.sh google-analytics.com
** Adding google-analytics.com to whitelist file
/usr/local/bin/whitelist.sh: line 85: /etc/pihole/whitelist.txt: Permission denied
** Modifying Hosts File
** Whitelisting a total of 7 domains...
** Refresh lists in dnsmasq...

I didn't have to sudo it before.

@PromoFaux
Copy link
Member

Interestingly running whitelist.sh as root changes the ownership of gravity.list to pi

@dschaper
Copy link
Member

Do you want to open a new issue for that one?

@PromoFaux
Copy link
Member

I'll do that when I get home once I've given it some thought. The question is.. SHOULD those files all be owned by root after install?

@dschaper
Copy link
Member

I don't think so, they should be owned by Pi for now. In the future they will all be owned by the pihole user, or which ever user Pi-Hole operates under.

@PromoFaux
Copy link
Member

The answer may lay in these commits by @jacobsalmela
image

This is the first time I've done a fresh install since then.

OK OK I'm going home now!!

@DonLexos
Copy link

Ok well tried the following:
remove the /var/www/html/admin
run /usr/bin/local/updateDashboard.sh

All files in /var/www/html/admin are owned by root again, Admin console still does not work. Could it be it tries to write somewhere that is not allowed?

@DonLexos
Copy link

Did an installation over the current one, notices a few curl errors along the process:
curl: (6) Could not resolve host: raw.githubusercontent.com

Not sure if it auto-retries, but raw.githubusercontent.com resolves fine (from the pi) when I dig the domain. Odd.

@dschaper
Copy link
Member

I don't think curl is set to auto-retry. Can you give the Pi a reboot?

@DonLexos
Copy link

Well checked the install script, only files that are downloaded from batch are the install scripts, seems to go wrong here

installScripts(){
$SUDO curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh
$SUDO curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh
$SUDO curl -o /usr/local/bin/whitelist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/whitelist.sh
$SUDO curl -o /usr/local/bin/blacklist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/blacklist.sh
$SUDO curl -o /usr/local/bin/piholeLogFlush.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/piholeLogFlush.sh
$SUDO curl -o /usr/local/bin/updateDashboard.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/updateDashboard.sh
$SUDO chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard}.sh
}

But only the first two. . .and even when I redo the curl and get the files that does not resolve it . .

Did the reboot, did not change anything in my pi admin interface

@DonLexos
Copy link

I can also attempt a clean installation if that helps, this is a Raspbian Jessy Lite system, not sure if the outcome would be the same. I installed Jessy, fundled with the keyboard settings, did an apt-get update/upgrade and then ran the installer. Whitelisted google analytics, not much else.

@dschaper
Copy link
Member

Doing a sudo curl is going to pull those as root, we may need to update that part of the script and do a sudo chown along with the sudo chmod...

@dschaper
Copy link
Member

If you want to try a clean install, go ahead. It shouldn't matter if you're using the lite or the full version, just a personal preference really. I use the lite because I run headless on a Class 4 card and it's quicker to reflash the smaller image.

@DonLexos
Copy link

Well, new installation Jese Lite, no apt-get anything (since the pi script does that when you install it), so vanilla installation, ran the script, reboot, it works, including the pi-hole admin console... intended behavior, but really no clue what I did different than before, other than I reinstalled on a different SD card which I doubt could be it.

@dschaper
Copy link
Member

Yeah, I don't know how a change in uSD cards could be a difference. I'll go ahead and close this one out, but if you run into issues again we can re-open in the future. Thanks for the assistance though!

@dschaper
Copy link
Member

Don't forget to resize your root partition though.

@DonLexos
Copy link

Oh I have, have to run raspi-config anyway to get out of the EN keyboard (and timezone) and set it to US intl. As far as I can tell it works :-) Thanks for your help guys!

@mattlward
Copy link

I am having this problem as well... It started after one of my recent upgrade/update and pihole reinstall for an upgrade. But, I am not exactly sure when it broke. It will run fine for a few hours and then just stops reporting stats. I have also done an uninstall and reinstall.

admin/api.php does return valid information as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Confirmed Verified as a bug to be resolved Help Wanted
Projects
None yet
Development

No branches or pull requests

5 participants