mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
better version of LCD display stats
This commit is contained in:
parent
9a2862de62
commit
11614263b8
1 changed files with 27 additions and 18 deletions
|
@ -1,19 +1,28 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Infinite loop that can be used to display ad domains on a Pi touch screen
|
# Displays Pi-hole stats on the Adafruit PiTFT 2.8" touch screen
|
||||||
# Continually watch the log file and display ad domains that are blocked being blocked
|
# Set the pi user to log in automatically and run this script from /etc/profile
|
||||||
# Set the pi user to log in automatically and add run this script from .bashrc
|
for (( ; ; ))
|
||||||
|
do
|
||||||
clear
|
clear
|
||||||
echo ""
|
# Displays a colorful Pi-hole logo
|
||||||
echo " +-+-+-+-+-+-+-+ "
|
toilet -f small -F gay Pi-hole
|
||||||
echo " Pi-hole "
|
|
||||||
echo " +-+-+-+-+-+-+-+ "
|
|
||||||
echo ""
|
|
||||||
echo " A black hole for"
|
|
||||||
echo " Internet Ads "
|
|
||||||
echo ""
|
|
||||||
echo " http://pi-hole.net"
|
|
||||||
echo ""
|
|
||||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
||||||
sleep 7
|
echo ""
|
||||||
# Look for only the entries that contain /etc/hosts, indicating the domain was found to be an advertisement
|
uptime | cut -d' ' -f11-
|
||||||
tail -f /var/log/daemon.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}'
|
echo "-------------------------------"
|
||||||
|
# Uncomment to continually read the log file and display the current domain being blocked
|
||||||
|
#tail -f /var/log/daemon.log | awk '/\/etc\/hosts/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/hosts") print $7; else;}'
|
||||||
|
|
||||||
|
today=$(date "+%b %e")
|
||||||
|
todaysQueryCount=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ {print $7}' | wc -l)
|
||||||
|
todaysQueryCountV4=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l)
|
||||||
|
todaysQueryCountV6=$(cat /var/log/daemon.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l)
|
||||||
|
todaysAdsEliminated=$(cat /var/log/daemon.log | grep "$today" | awk '/\/etc\/hosts/ {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 5
|
||||||
|
done
|
Loading…
Reference in a new issue