Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #######################
- #
- # pihole log filter - 26-January-2022 - Hack5190 (at) protonmail (dot) com
- #
- # usage: tail -f /var/log/pihole.log | ~/monitor/highlight.sh 1.1.1.1 0.0.0.0
- #
- # 1.1.1.1 is the IP to trap / display - it will be highlighted in Yellow
- # 0.0.0.0 will be highlight in Red to show blocked - use 127.0.0.1 to highlight forwarded requests
- #
- # FYI: the counter displayed between query results is the # of non-matching lines
- #
- #######################
- # Text color
- red=$(tput bold;tput setaf 1)
- yellow=$(tput bold;tput setaf 3)
- # The loop
- reset=$(tput sgr0)
- count=0
- while read line; do
- if (echo $line | grep $1 > /dev/null) ; then
- printf "\r"
- read line_2
- echo $line | sed -ue "s/\($1\)/$yellow\1$reset/; s/\($2\)/$red\1$reset/"
- echo $line_2 | sed -ue "s/\($1\)/$yellow\1$reset/; s/\($2\)/$red\1$reset/"
- else
- (( count++ ))
- printf "%s\r" "$count"
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement