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

Advanced stats #25

Merged
merged 24 commits into from
Feb 13, 2016
Merged

Advanced stats #25

merged 24 commits into from
Feb 13, 2016

Conversation

bricej13
Copy link
Contributor

Let's try this again.

I merged the changes into the devel branch changes. I ripped out the datatables piece as data.php isn't creating the proper data to support it.

Here's the original pull request info:

Added the following UI elements:

  • A graph of queries over time
  • Top chart of valid queries
  • Top chart of advertisement queries
  • Chart of most recent queries
  • Removed 'More Info ->' links from top boxes to reduce confusion

Architecture changes

  • sed/awk/wc replaced with PHP
  • Moved data generation to separate file data.php file
  • Data.php is used both in index.html and api.php

screen shot 2016-01-27 at 11 19 20 pm

@AzureMarker
Copy link
Contributor

You have a merge conflict in api.php

@DonLexos
Copy link

Played with this and it looks great! Not entirely sure what is causing the conflict (getting used to how github and the github software works), noticed your version on the bottom is 2.2 and the master is at 2.4 so could be you based this on that code?

@AzureMarker
Copy link
Contributor

The current versioning system is based on the Pi-hole, not the web interface. I'm currently changing it so that there will be separate versions for both.

@bricej13 If you look in api.php, you'll see two versions of it, separated by a divider. You need to choose one or combine them. You do this by just modifying the file to how you want it to look (removing the stuff git put in). You can read more about it here.

@AzureMarker
Copy link
Contributor

You should move your JS code to index, after php loads in the footer. Only the index needs that code, and it will error on the list pages.

@AzureMarker
Copy link
Contributor

You may want to look into using ajax (through jQuery) to populate the tables. This will lower the load time of the page (which is a little long right now).

@bricej13
Copy link
Contributor Author

I fixed the merge conflict in api.php and moved the JS code to index.php.

Using Ajax is a good idea. This would make it feasible to load entire lists instead of the first few elements.

@Mcat12 would you rather I create a new branch for adding the Ajax functionality or tack it on to this one?

@AzureMarker
Copy link
Contributor

You can work on it in this one. Also, maybe you should separate out the original api from the other stuff. This will allow you to load the original stats with the page and use ajax for the lists of domains and such.

@AzureMarker
Copy link
Contributor

Are your calculations taking into account ipv6? It's doubling the amount. Remember that users could have either ipv4 or both.

@PromoFaux
Copy link
Member

Ah yeah, you need to test for IPv6, which is pretty much as simple as checking for the existence of /etc/pihole/.useIPv6

From chronometer.sh:

function CalcBlockedDomains(){
    CheckIPv6
    if [ -e "$gravity" ]; then
        #Are we IPV6 or IPV4?
        if [[ -n $piholeIPv6 ]];then
            #We are IPV6
            blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
        else
            #We are IPV4
            blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1}')
        fi
    else
        blockedDomainsTotal="Err."
    fi
}
function CheckIPv6(){
    piholeIPv6file="/etc/pihole/.useIPv6"
    if [[ -f $piholeIPv6file ]];then
        # If the file exists, then the user previously chose to use IPv6 in the automated installer
        piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
    fi
}

@DonLexos
Copy link

DonLexos commented Feb 1, 2016

I am not sure if I have the latest files but if I do the 2.5 release breaks a few things in the top domains/top advertisers.

@PromoFaux
Copy link
Member

More than possible, do you have @bricej13 's version checked out on your pi? Because the changes aren't merged into the main site yet..

@DonLexos
Copy link

DonLexos commented Feb 1, 2016

I grabbed it yesterday so I believe I have, but I am aware there is a merge conflict with master. Just wanted to test it out, looks good ! :-)

@PromoFaux
Copy link
Member

I agree, I like the graphs a lot!

@PromoFaux
Copy link
Member

But yeah, we may have broken functionality on it during the 2.5 update

@DonLexos
Copy link

DonLexos commented Feb 2, 2016

Some files are moved, not sure if the logfile is filled differently with more information but instead of domain names now query[A] is shown. And my top advertiser is /etc/pihole/gravity.list :-)

Hope @bricej13 can resolve this.

@bricej13
Copy link
Contributor Author

bricej13 commented Feb 3, 2016

Made some updates:

  • Updated API to allow data to be retrieved independently
  • Moved most data calls to ajax
  • Fixed total blocked domains number for ipv6 users
  • Fixed Top Ads & Top Queries tables to show domains properly
  • Fixed time column on Recent Queries table

@AzureMarker
Copy link
Contributor

Good work. I'll test as soon as I get home!

@jmacdowall
Copy link

This is easy to fix. Edit /var/www/html/admin/data.php:

Just change a couple of lines:
OLD:
$domain = trim($exploded[5]);
NEW:
$domain = trim($exploded[6]);

OLD:
$queryArray['domain'] = trim($exploded[5]);
$queryArray['ip'] = trim($exploded[7]);
NEW:
$queryArray['domain'] = trim($exploded[6]);
$queryArray['ip'] = trim($exploded[8]);

@bricej13 - sweet graph!!

@AzureMarker
Copy link
Contributor

What are you fixing @jmacdowall ?

@bricej13
Copy link
Contributor Author

More Charts!

  • Query Types: Shows what types of queries are being made (i.e. MX, AA, AAA, SOA, etc.)
  • Top Clients: Shows all clients making requests and the amount of requests being made
  • Forward Destinations: External DNS servers being forwarded to (i.e. 8.8.8.8, 8.8.4.4)

screen shot 2016-02-11 at 11 53 51 pm

@jacobsalmela
Copy link
Contributor

Beautiful...We'll check this out. Thanks!

@AzureMarker
Copy link
Contributor

Looks good. If there's any way to have all the hours of the day show up on the graph, that would be nice. Everything looks so nice!

@bricej13
Copy link
Contributor Author

@Mcat12 I fixed the issue where hours would be missing from the graph. It should now show all hours between the first query of the day and the last.

I also added a new page (the Query Log) that has a table of all of the queries for the day.

screen shot 2016-02-13 at 12 04 24 am

@bricej13
Copy link
Contributor Author

@jacobsalmela How are you coming on getting the whitelist/blacklist files updated? Could we strip out the editing piece for now? That would allow us to get the new dashboard out while a solution is worked on for editing the lists.

@jacobsalmela
Copy link
Contributor

@bricej13 I'm good with that. Do you want to update this PR with the white and blacklist links removed from the sidebar (and also fix the conflicts).

@AzureMarker
Copy link
Contributor

@jacobsalmela we can merge this and when melting into master just not merge the whitelist stuff. I think there's an option to allow you to edit the merge commit before merging.

@AzureMarker
Copy link
Contributor

Checkout --no-commit here.

@AzureMarker AzureMarker reopened this Feb 13, 2016
@AzureMarker
Copy link
Contributor

Shoot! This touchscreen is wacky!

@AzureMarker
Copy link
Contributor

I was trying to comment, not close! -.-

@bricej13
Copy link
Contributor Author

It should be ready to merge now.

@AzureMarker
Copy link
Contributor

Serbs stable enough here. I'll merge soon if no one objects.

@jacobsalmela
Copy link
Contributor

I'm OK with it. It's going into devel so we can work out any final issues there.

AzureMarker added a commit that referenced this pull request Feb 13, 2016
@AzureMarker AzureMarker merged commit 8a01b42 into pi-hole:devel Feb 13, 2016
@PromoFaux
Copy link
Member

Wow, this page is looking flashy as hell now. 👍

@jacobsalmela
Copy link
Contributor

+1

@DonLexos
Copy link

Loving this! One (tiny) thing, Query log time stamps are shown like 2016-02-15T02:01:04 but its Mon 15 Feb 01:00:59 CET 2016 here now. They are 1 hour off.. and I can't figure out why. (date taken from date at the pi (reckoning it uses that date).

@jmacdowall
Copy link

My timestamps are off by 4 hours—same as my time zone offset. Coincidence?

I set the time “wrong” on my raspberry to fix it…

John MacDowall
UDP SysAdmin [Contractor]
Building 50, Room 5523
National Institutes of Heath
Bethesda, MD
301-827-4433

From: Alex [mailto:notifications@github.com]
Sent: Sunday, February 14, 2016 7:03 PM
To: pi-hole/AdminLTE
Cc: Macdowall, John (NIH/NHGRI) [C]
Subject: Re: [AdminLTE] Advanced stats (#25)

Loving this! One (tiny) thing, Query log time stamps are shown like 2016-02-15T02:01:04 but its Mon 15 Feb 01:00:59 CET 2016 here now. They are 1 hour off.. and I can't figure out why.


Reply to this email directly or view it on GitHubhttps://github.com//pull/25#issuecomment-184008940.

@DonLexos
Copy link

Oh that must be it, CET is GMT+1 .. Funny thing is, I checked the logfiles, there the time is perfect and ok, and I ran raspi-config to make sure it is set correctly to begin with (and it was).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants