Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Displays Pi-hole stats on the Adafruit PiTFT 2.8" touch screen
  3. # Set the pi user to log in automatically and run this script from /etc/profile
  4. # (c) 2015 by Jacob Salmela
  5. # This file is part of Pi-hole.
  6. #
  7. # Pi-hole is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 2 of the License, or
  10. # (at your option) any later version.
  11. for (( ; ; ))
  12. do
  13. clear
  14. # Displays a colorful Pi-hole logo
  15. toilet -f smbraille -F gay Pi-hole
  16. echo " $(ifconfig wlan0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
  17. echo ""
  18. echo " $(uptime | cut -d' ' -f11-)"
  19. echo "---------------------"
  20. # Uncomment to continually read the log file and display the current domain being blocked
  21. #tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'
  22.  
  23. today=$(date "+%b %e")
  24. todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l)
  25. todaysQueryCountV4=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l)
  26. todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l)
  27. todaysAdsEliminated=$(cat /var/log/pihole.log | grep "$today" | awk '/\/etc\/pihole\/gravity.list/ {print $7}' | wc -l)
  28. dividend=$(echo "$todaysAdsEliminated/$todaysQueryCount" | bc -l)
  29. fp=$(echo "$dividend*100" | bc -l)
  30. percentAds=$(echo ${fp:0:4})
  31.  
  32. echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6"
  33. echo "Pi-holed: $todaysAdsEliminated ($percentAds%)"
  34. sleep 42
  35. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement