Skip to content

Instantly share code, notes, and snippets.

@asgrim
Created March 2, 2018 18:22
Show Gist options
  • Save asgrim/f97905660f71621b971603bf52c9c1ae to your computer and use it in GitHub Desktop.
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
#!/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
#!/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