Created
January 18, 2017 01:13
-
-
Save SkaTeMasTer/fbdfb8ad9fc4737648ae7d0e3a13c84d to your computer and use it in GitHub Desktop.
Displays Pi-hole stats on the Adafruit PiTFT 2.8" touch screen # Set the pi user to log in automatically and run this script from /etc/profile # (c) 2015 by Jacob Salmela # This file is part of Pi-hole.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Displays Pi-hole stats on the Adafruit PiTFT 2.8" touch screen | |
| # Set the pi user to log in automatically and run this script from /etc/profile | |
| # (c) 2015 by Jacob Salmela | |
| # This file is part of Pi-hole. | |
| # | |
| # Pi-hole is free software: you can redistribute it and/or modify | |
| # it under the terms of the GNU General Public License as published by | |
| # the Free Software Foundation, either version 2 of the License, or | |
| # (at your option) any later version. | |
| for (( ; ; )) | |
| do | |
| clear | |
| # Displays a colorful Pi-hole logo | |
| toilet -f smbraille -F gay Pi-hole | |
| echo " $(ifconfig wlan0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)" | |
| echo "" | |
| echo " $(uptime | cut -d' ' -f11-)" | |
| echo "---------------------" | |
| # Uncomment to continually read the log file and display the current domain being blocked | |
| #tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}' | |
| today=$(date "+%b %e") | |
| todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l) | |
| todaysQueryCountV4=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l) | |
| todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l) | |
| todaysAdsEliminated=$(cat /var/log/pihole.log | grep "$today" | awk '/\/etc\/pihole\/gravity.list/ {print $7}' | wc -l) | |
| dividend=$(echo "$todaysAdsEliminated/$todaysQueryCount" | bc -l) | |
| fp=$(echo "$dividend*100" | bc -l) | |
| percentAds=$(echo ${fp:0:4}) | |
| echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6" | |
| echo "Pi-holed: $todaysAdsEliminated ($percentAds%)" | |
| sleep 42 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment