Created
March 2, 2018 18:22
-
-
Save asgrim/f97905660f71621b971603bf52c9c1ae to your computer and use it in GitHub Desktop.
Used to use this on browscap-site to watch for IP abuse and block them
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/bash | |
set -uox pipefail | |
RUN=true | |
TIMEOUT=60 | |
trap 'kill -INT -$PID; RUN=false' INT | |
file="/tmp/ips" | |
# varnishncsa > $file | |
while $RUN; do | |
timeout 60s varnishncsa -F "%{CF-CONNECTING-IP}i %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i"" > $file & | |
PID=$! | |
wait $PID | |
done |
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/bash | |
file="/tmp/ips" | |
cat $file | cut -f1 -d" " | sort -n | uniq -c | sort -nr | head -n 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment