Skip to content

Instantly share code, notes, and snippets.

@scriptzteam
Forked from catacs/fail2ban-report
Created October 13, 2016 20:54
Show Gist options
  • Save scriptzteam/9e5576a38e32f9364b43b4d469c49d9e to your computer and use it in GitHub Desktop.
Save scriptzteam/9e5576a38e32f9364b43b4d469c49d9e to your computer and use it in GitHub Desktop.
Fail2ban log statistics
#!/bin/bash
echo "Baned last log"
awk '($(NF-1) = /Ban/){print $NF}' /var/log/fail2ban.log | sort | uniq -c | sort -n
echo "------------ Baned in all files --------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | sort | uniq -c
echo "------------ Baned by subnet --------------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $NF}' | awk -F\. '{print $1"."$2"."}' | sort | uniq -c | sort -n | tail
echo "------------ Baned by date -------------------------"
zgrep -h "Ban " /var/log/fail2ban.log* | awk '{print $5,$1}' | sort | uniq -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment