include $today in functions and grep them to make it daily

This commit is contained in:
Tommy Huff 2016-10-22 22:12:33 -04:00
parent 92249365b4
commit 63a939b636

20
pihole
View file

@ -160,12 +160,14 @@ statsBlockedDomains() {
} }
statsQueriesToday() { statsQueriesToday() {
local queriesToday=$(cat /var/log/pihole.log | cut -d" " -f5 | grep query | wc -l) local today=$(date "+%b %e")
local queriesToday=$(cat /var/log/pihole.log | grep "${today}" | cut -d" " -f5 | grep query | wc -l)
echo ${queriesToday} echo ${queriesToday}
} }
statsBlockedToday() { statsBlockedToday() {
local blockedToday=$(grep /etc/pihole/gravity.list /var/log/pihole.log | grep -v read | wc -l) local today=$(date "+%b %e")
local blockedToday=$(grep /etc/pihole/gravity.list /var/log/pihole.log | grep "${today}" | grep -v read | wc -l)
echo ${blockedToday} echo ${blockedToday}
} }
@ -177,13 +179,18 @@ stats() {
statsQueriesToday statsQueriesToday
elif [[ $1 == "blocked" ]] ; then elif [[ $1 == "blocked" ]] ; then
statsBlockedToday statsBlockedToday
else
echo "::: Any heading can be called to just return that value"
echo ":::"
echo -n "::: list: "
statsBlockedDomains
echo -n "::: hits: "
statsQueriesToday
echo -n "::: blocked: "
statsBlockedToday
fi fi
} }
helpFunc() { helpFunc() {
echo "::: Control all PiHole specific functions!" echo "::: Control all PiHole specific functions!"
echo ":::" echo ":::"
@ -207,6 +214,7 @@ helpFunc() {
echo "::: enable Enable Pi-Hole DNS Blocking" echo "::: enable Enable Pi-Hole DNS Blocking"
echo "::: disable Disable Pi-Hole DNS Blocking" echo "::: disable Disable Pi-Hole DNS Blocking"
echo "::: restartdns Restart dnsmasq" echo "::: restartdns Restart dnsmasq"
echo "::: stats Display some statistics"
exit 0 exit 0
} }