#!/bin/bash
# ein kleines script zur auswertung wer denn da in den letzten beiden logfiles von der dynip erwischt wurde 
# bitte passt es evtl. auf eure bedürfnisse an.
# Verbesserungsvorschläge nehme ich gerne entgegen unter driessen@fblan.de
# viel spaß damit
# NOQUEUE: reject: RCPT from(.*):(.*)Client host rejected: 

CURRLOG=/var/log/mail.log
LASTLOG=/var/log/mail.log.0
ARCHIVLOG=/var/log/mail.log.*.gz

cat $LASTLOG $CURRLOG | egrep "Client not allowed hel" | cut -d "[" -f 3 | cut -d "]" -f 1 | sort | uniq -c | awk '{print $1, $2}' 

#|while read line
#do
# ipaddress=`echo $line  | cut -d " " -f 2`
# anzahl=`echo $line | cut -d " " -f 1`
# reverse_dns=`dig +short -x ${ipaddress}`
# dynipreg=`postmap -q ${reverse_dns} pcre:/etc/postfix/maps/dynip|cut -d ")" -f 2`

#     echo "na wen haben wir denn da erwischt:	$ipaddress	$anzahl"
#done

zcat $ARCHIVLOG | egrep "Client not allowed hel" | cut -d "[" -f 3 | cut -d "]" -f 1 | sort | uniq -c | awk '{print $1, $2}' 
#|while read line

#do
# ipaddress=`echo $line  | cut -d " " -f 2`
# anzahl=`echo $line | cut -d " " -f 1`
# reverse_dns=`dig +short -x ${ipaddress}`
# dynipreg=`postmap -q ${reverse_dns} pcre:/etc/postfix/maps/dynip|cut -d ")" -f 2`

#   echo "archiv wen haben wir denn da erwischt:	$ipaddress	$anzahl"
# done

