#!/bin/sh
#
# $Id: spam-check.sh,v 1.1 2003/12/23 00:47:08 dope Exp dope $
# 
# Copyright by Christian Schneider <strcat@gmx.net>
# 
# Filename       : ~/bin/spam-check.sh
# Purpose        : create a simple statistic (for Mailfilter)
# Author         : Christian Schneider <strcat@gmx.net>
# Latest release : <http://strcat.neessen.net/>
#
# Last modified: [ 2003-12-23 01:47:33 ]

LOG=/home/dope/.mailfilter/mailfilter.log
SLOG="`head -n 1 $LOG | awk '{print $6 " " $7 " " $8 " " $9 " " $10}'`"
ELOG="`tail -n 10 $LOG  | grep querying | tail -n 1 | awk '{print $6 " " $7 " " $8 " " $9 " " $10}'`"
MESSAGES="`grep -c Deleted /home/dope/.mailfilter/mailfilter.log`"
RESU="`grep Examining ~/.mailfilter/mailfilter.log | awk '{x=x+$3}; END {print x}'`"
TIME="`date +%c | sed 's/  / /g'`"
echo ""
echo -e "\033[1;31mSpamstats for `hostname`\033[0;m"
echo -e ""
echo -e "Date.............:" $TIME
echo -e "First Log entry..:" $SLOG
echo -e "Last Log entry...:" $ELOG
echo -e "Examining Mails..:" $RESU
echo -e "Deleted Mails....:" $MESSAGES
echo ""
echo "Top 10 Subjects"
cat $LOG |awk '/Deleted/ { print $NF }'|sed -e 's/]//g' -e "s/'//g"| sort|uniq -c|sort -r | head -n 10
echo ""
echo "Top 10 X-Mailer"
grep -i X-Mailer $LOG | getmailer.pl | awk '{print $3 " " $4 " " $5}' | sort | uniq -c | sort -r | head -n 10
