Last active
December 18, 2019 14:01
-
-
Save oerdnj/e5d83df14667b252ebf766e9ebaf360e to your computer and use it in GitHub Desktop.
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/sh | |
logfile=${1:-/var/log/nginx/packages.sury.org-access.log} | |
file_limit=480 # can go as low as 240 in the future | |
deb_limit=48 # can go as low as 24 in the future | |
perl -n -e '/^([^ ]+) ([^ ]+) ([^ ]+) (\[[^\]]+\]) "(.*) (.*) (.*)" ([0-9\-]+) ([0-9\-]+) "(.*)" "(.*)"/; print "$1 $6\n"' -- "$logfile" | sort | uniq -c | awk -v fl="$file_limit" dl="$deb_limit" '{ if ($1 > fl || (match($3,"\.deb") && $1 > dl)) { print $2 } }' | sort -u | xargs -i printf "deny %s;\n" "{}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment