#!/usr/bin/env bash # Author: Oliver Ladner # License: LGPL # # Displays a summary of failed IMAP login attempts by country postfix_logfile='/var/log/mail.log' for ip in $(grep 'auth failed' $postfix_logfile | awk {'print $17'} | sed 's/,//' | awk -F'=' {'print $2'} | sort -n | uniq); do geoiplookup $ip; done | sort | uniq -c | sort -n | tail -10