Created
January 23, 2014 09:37
-
-
Save cedricbonhomme/8575675 to your computer and use it in GitHub Desktop.
Mail IP banned by fail2ban.
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 | |
servername="Server" | |
for ip in echo `grep -i unban /var/log/fail2ban.log | awk '{print $NF}' | tail -n 10` | |
do | |
for email in `whois $ip | perl -wne'while(/[\w\.\-]+@[\w\.\-]+\w+/g){print "$&\n"}' | sort | uniq` | |
do | |
echo "Sending email to $email..." | |
echo "Hi, | |
The IP $ip has just been banned by Fail2Ban. | |
Here are more information about $ip: | |
`whois $ip` | |
Regards," | mail -s "$servername banned $ip" $email; | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment