]> git.sven.stormbind.net Git - sven/scripts.git/blob - stormbind/gif-reject-stats.sh
Import stormbind script
[sven/scripts.git] / stormbind / gif-reject-stats.sh
1 #!/bin/sh
2 # stats about gif file rejects via postfix pcre body_checks
3 # sven@timegate.de
4
5 MAILLOG="/var/log/mail.log"
6 RJL="/tmp/gifrejects.$$"
7
8 grep "reject: body R0lGOD" $MAILLOG > $RJL
9
10 printf "\n"
11 echo "Mail rejects with gif file statistics for host $(hostname)"
12 echo "=========================================================="
13 echo "Generated on $(date)"
14 printf "\n"
15 echo "Mail log starts on: $(head -n 1 $MAILLOG|awk '{print $1" "$2" "$3}')"
16 echo "First reject on: $(head -n 1 $RJL|awk '{print $1" "$2" "$3}')"
17 echo "Last reject on: $(tail -n 1 $RJL|awk '{print $1" "$2" "$3}')"
18 echo "Mail log ends on: $(tail -n 1 $MAILLOG|awk '{print $1" "$2" "$3}')" 
19 echo "We have $(wc -l $RJL|awk '{print $1}') rejects in total in the logfile."
20 printf "\n"
21
22 echo "Rejects sorted by number and sender address"
23 awk '{print $12}' $RJL|grep from|sed -e 's/from=//g'|sort|uniq -c|sort -rn
24 printf "\n"
25
26 echo "Rejects sorted by number and destination address"
27 awk '{print $13}' $RJL|grep to|sed -e 's/to=//g'|sort|uniq -c|sort -nr
28 printf "\n"
29
30 echo "Rejects sorted by number and sender-destination address combinations"
31 awk '{print $12" "$13}' $RJL|grep '^from'|sed -e 's/from=//g' -e 's/to=//g'|sort|uniq -c|sort -nr|awk '{print "\t"$1"\tFrom: "$2" To: "$3}'
32
33 # CLEAN UP
34 rm $RJL