From e88f58c34ecba8969e458fbcc0e80e1204f0dde5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 22 Dec 2016 18:45:53 +0100 Subject: [PATCH 1/4] Remove grpping for today's log entries, because we flush the log every day --- advanced/Scripts/chronometer.sh | 4 +--- advanced/Scripts/update.sh | 0 2 files changed, 1 insertion(+), 3 deletions(-) mode change 100644 => 100755 advanced/Scripts/update.sh diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index c4b3d865..97777802 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -15,8 +15,6 @@ piLog="/var/log/pihole.log" gravity="/etc/pihole/gravity.list" -today=$(date "+%b %e") - . /etc/pihole/setupVars.conf CalcBlockedDomains() { @@ -35,7 +33,7 @@ CalcBlockedDomains() { CalcQueriesToday() { if [ -e "${piLog}" ]; then - queriesToday=$(cat "${piLog}" | grep "${today}" | awk '/query/ {print $6}' | wc -l) + queriesToday=$(cat "${piLog}" | awk '/query/ {print $6}' | wc -l) else queriesToday="Err." fi diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh old mode 100644 new mode 100755 From 9b0390c9da5ee21f87b3e99ab9a099a8b294c0cb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 22 Dec 2016 18:53:44 +0100 Subject: [PATCH 2/4] Space to Tab --- advanced/Scripts/chronometer.sh | 2 +- advanced/Scripts/update.sh | 0 2 files changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 advanced/Scripts/update.sh diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 97777802..a2482d0d 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -102,7 +102,7 @@ normalChrono() { echo "Blocking: ${blockedDomainsTotal}" echo "Queries: ${queriesToday}" #same total calculation as dashboard - echo "Pi-holed: ${blockedToday} (${percentBlockedToday}%)" + echo "Pi-holed: ${blockedToday} (${percentBlockedToday}%)" sleep 5 done diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh old mode 100755 new mode 100644 From bcf8139708c529db7c2b76e88af7e5bcf1b4b42e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 22 Dec 2016 18:55:14 +0100 Subject: [PATCH 3/4] Removed cat where we don't need it --- advanced/Scripts/chronometer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index a2482d0d..702ed1c9 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -33,7 +33,7 @@ CalcBlockedDomains() { CalcQueriesToday() { if [ -e "${piLog}" ]; then - queriesToday=$(cat "${piLog}" | awk '/query/ {print $6}' | wc -l) + queriesToday=$(awk '/query/ {print $6}' < "${piLog}" | wc -l) else queriesToday="Err." fi @@ -41,7 +41,7 @@ CalcQueriesToday() { CalcblockedToday() { if [ -e "${piLog}" ] && [ -e "${gravity}" ];then - blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l) + blockedToday=$(awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' < "${piLog}" | wc -l) else blockedToday="Err." fi From a4f58b0a22ff9e0afdaa08db34c771f3f6d98a4c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 22 Dec 2016 19:09:37 +0100 Subject: [PATCH 4/4] Look for "query[" instead of "query" to avoid false-positives, like listed below root@raspberrypi:/etc/.pihole# grep 'query' /var/log/pihole.log | grep -v 'query\[' Dec 22 16:29:50 dnsmasq[30801]: forwarded code.jquery.com to 208.67.222.222 Dec 22 16:29:50 dnsmasq[30801]: reply code.jquery.com is Dec 22 16:29:50 dnsmasq[30801]: reply code.jquery.netdna-cdn.com is 94.31.29.54 Dec 22 16:29:50 dnsmasq[30801]: reply code.jquery.netdna-cdn.com is 23.111.11.3 Dec 22 16:29:50 dnsmasq[30801]: reply code.jquery.netdna-cdn.com is 198.232.125.113 --- advanced/Scripts/chronometer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 702ed1c9..a28bb868 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -33,7 +33,7 @@ CalcBlockedDomains() { CalcQueriesToday() { if [ -e "${piLog}" ]; then - queriesToday=$(awk '/query/ {print $6}' < "${piLog}" | wc -l) + queriesToday=$(awk '/query\[/ {print $6}' < "${piLog}" | wc -l) else queriesToday="Err." fi