This is a script you can use to monitor the performance of your mailreaver spam filter. It relies on the reavercache to count the different classes of email.

To make it work you will need to change the CRMDIR to point to the reavercache directory.

If you call it with no command line paramaters it will give you the stats for yesterday. If you call it with -i it will give you the stats for the last 30 days.

#!/bin/bash
#
# Copyright 2008 Jason Lewis <jason at dickson dot st>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# $Id: crm114dailystats,v 1.8 2008/02/11 06:17:30 jason Exp jason $ 
#
#
#
# ---------------------------------------------------------------------------
# This script will give you counts of ham/spam on a daily basis. 
# by default it outputs yesterdays counts only, on one line ready to put into
# a log file for later processing
# the option -i will give you the last n days including today
# 
# 

# change this to point to your reaver_cache
CRMDIR="$HOME/.crm114working/reaver_cache/"


#############################################
# you probably don't need to edit anything below here
#############################################
STARTDAYS=1
ENDDAYS=1
INTERACTIVEDAYS=30
PRINTFORMAT="%-10s%3s%7s%11s%11s%10s%10s%8s%13s%6s\n"
FINDOPTIONS="-type f -daystart -mtime"


# if we have more than 1 paramater, and it is not -i, quit with a help message
if [[ $# -ge 1 ]] && [[ "$1" != "-i" ]]  ;
then
    echo Usage: $(basename $0) "[-i]"
    exit
fi


# if we are being run interactively, do counts for last INTERACTIVEDAYS days including today
if [[ $1 == "-i" ]];
then
    INTERACTIVE=true
    STARTDAYS=0
    ENDDAYS=$INTERACTIVEDAYS
fi
[[ $INTERACTIVE ]] && printf "$PRINTFORMAT" "DATE" "i" "EMPTY" "KNOWN_GOOD" "KNOWN_SPAM" "PROB_GOOD" "PROB_SPAM" "UNSURES" "UNCLASSIFIED" "TEXTS" 
for ((i=$STARTDAYS; i<=$ENDDAYS; i++)); do
  EMPTY=$(find $CRMDIR/empty $FINDOPTIONS $i | wc -l)
  KNOWN_GOOD=$(find $CRMDIR/known_good $FINDOPTIONS $i | wc -l)
  KNOWN_SPAM=$(find $CRMDIR/known_spam $FINDOPTIONS $i | wc -l)
  PROB_GOOD=$(find $CRMDIR/prob_good $FINDOPTIONS $i | wc -l)
  PROB_SPAM=$(find $CRMDIR/prob_spam $FINDOPTIONS $i | wc -l)
  TEXTS=$(find $CRMDIR/texts $FINDOPTIONS $i | wc -l)
  UNSURES=$(($TEXTS - $PROB_GOOD - $PROB_SPAM ))
  UNCLASSIFIED=$(($TEXTS - $KNOWN_GOOD  - $KNOWN_SPAM - $PROB_GOOD - $PROB_SPAM))
#  printf "$PRINTFORMAT" "$i" "$EMPTY" "$KNOWN_GOOD" "$KNOWN_SPAM" "$PROB_GOOD" "$PROB_SPAM" "$TEXTS"
  printf "$PRINTFORMAT" $(date --rfc-3339=date --date "now $i days ago") "$i" "$EMPTY" "$KNOWN_GOOD" "$KNOWN_SPAM" "$PROB_GOOD" "$PROB_SPAM" "$UNSURES" "$UNCLASSIFIED" "$TEXTS" 
done