Last active
September 12, 2019 17:25
-
-
Save dkittell/74dc56f832ea2b7da1c9cc9fcbb766ca to your computer and use it in GitHub Desktop.
Pi-Hole Statistics
This file contains 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
#!/bin/sh | |
# Pi-Hole Statistics | |
# | |
# | |
# Created by David Kittell on 3/21/17. | |
# | |
clear | |
# Install Prerequisites - Start | |
# Install JQ | |
# sudo apt-get install jq | |
# Install IPCalc | |
# sudo apt-get install ipcalc | |
# Install Network Manager (nmcli) | |
# sudo apt-get install network-manager | |
# Install Prerequisites - Stop | |
# Variables - Start | |
#uptimeFormatted=$(uptime | sed 's|,||' | awk '{sub(":", " hours, ", $3); print "Uptime: " $3 " minutes"}') | |
uptimeFormatted=$(uptime | awk -F'( |,|:)+' '{print $6,$7",",$8,"hours,",$9,"minutes."}'); | |
json=$(curl -s -X GET http://127.0.0.1/admin/api.php?summaryRaw) | |
#echo ${json} | |
#uptime=$(echo ${json} | jq ".server_up_time" | sed 's/"//g') | |
domains=$(echo ${json} | jq ".domains_being_blocked") | |
queries=$(echo ${json} | jq ".dns_queries_today") | |
blocked=$(echo ${json} | jq ".ads_blocked_today") | |
percentage=$(printf "%0.2f\n" $(echo ${json} | jq ".ads_percentage_today")) | |
# Variables - Stop | |
#lsb_release -a | |
OS=$(lsb_release -i | cut -d ":" -f2 | tr -d '[:space:]') | |
OSCode=$(lsb_release -c | cut -d ":" -f2 | tr -d '[:space:]') | |
OSVer=$(lsb_release -r | cut -d ":" -f2 | tr -d '[:space:]') | |
#echo "$OS $OSCode $OSVer" | |
sCPU=$(grep -c ^processor /proc/cpuinfo ) | |
#echo "CPU: $sCPU" | |
sRamGB=$(cat /proc/meminfo | grep MemTotal | cut -d ":" -f 2 | tr -d '[:space:]' | sed 's/.\{2\}$//' | awk '{$1=$1/(1024^2); print int($1+0.5),"GB";}') | |
#if [ "$sRamGB" == "0 GB" ]; then | |
# sRamGB=$(cat /proc/meminfo | grep MemTotal | cut -d ":" -f 2 | tr -d '[:space:]' | sed 's/.\{2\}$//' | awk '{ foo = $1 / 1024 ; print foo " MB" }') | |
#fi | |
clear | |
echo $(cat /proc/device-tree/model) | |
echo " OS: $OS $OSCode $OSVer" | |
echo " Hostname: $(hostname)" | |
echo " CPU: $sCPU" | |
echo " RAM: $sRamGB" | |
#echo " System Uptime: $(uptime | awk -F'( |,|:)+' '{print $6,$7",",$8,"hours,",$9,"minutes."}')" | |
echo " System Uptime: $uptimeFormatted" | |
echo "-----------------------------------------------------------------------" | |
echo "Ad Filter Stats" | |
echo " Total Blocked Hosts: ${domains}" | |
echo " Total Queries: ${queries}" | |
echo " Total Blocked: ${blocked} (${percentage}%)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment