Skip to content

Instantly share code, notes, and snippets.

@polprog
Created April 4, 2017 16:34
Show Gist options
  • Save polprog/96d0bd410c31eaec699a61e1ff6be6ba to your computer and use it in GitHub Desktop.
Save polprog/96d0bd410c31eaec699a61e1ff6be6ba to your computer and use it in GitHub Desktop.
#!/bin/bash
#Analyze fail2ban logs and make a top 10 list of abusers!
if [[ $1 == "today" ]]; then
echo "Top abusers today:"
grep "Ban " /var/log/fail2ban.log | grep `date +%Y-%m-%d` | awk '{print $NF}' | sort | awk '{print $1,"("$1")"}' | logresolve | uniq -c | sort -n
else
echo "Top abusers:"
grep "Ban " /var/log/fail2ban.log | awk -F[\ \:] '{print $10,$8}' | sort | uniq -c | sort -n
echo "Run '$0 today' to get todays suspicious activity"
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment