Am 17.02.2015 um 15:23 schrieb Reindl Harald:
Am 17.02.2015 um 15:19 schrieb LuKreme:
On 16 Feb 2015, at 12:01 , Reindl Harald <h.rei...@thelounge.net> wrote:
given that 24266 messages had BAYES_00 with a total number of 30401
delivered mails in the current month that training strategy seems to
work well

[root@mail-gw:~]$ bayes-stats.sh

What is bayes-stats.sh?

as simple shell script

nicer version attached as plain-text file
using now bash + bc + printf for % and formatting

removed the su-calls by place it in a worker-dir and call that with "su" from a script in PATH, well output looks now like below

bayes-stats.sh
0.000          0          3          0  non-token data: bayes db version
0.000          0      10606          0  non-token data: nspam
0.000          0      10688          0  non-token data: nham
0.000          0    1387376          0  non-token data: ntokens
0.000          0  993467899          0  non-token data: oldest atime
0.000          0 1424264407          0  non-token data: newest atime
0.000 0 1424264867 0 non-token data: last journal sync atime
0.000          0          0          0  non-token data: last expiry atime
0.000 0 0 0 non-token data: last expire atime delta 0.000 0 0 0 non-token data: last expire reduction count

insgesamt 35M
-rw------- 1 sa-milt sa-milt 2,6M 2015-02-18 14:07 bayes_seen
-rw------- 1 sa-milt sa-milt  40M 2015-02-18 14:07 bayes_toks
-rw------- 1 sa-milt sa-milt   98 2015-02-17 11:37 user_prefs

BAYES_00     28000   75.84 %
BAYES_05       437    1.18 %
BAYES_20       546    1.47 %
BAYES_40       597    1.61 %
BAYES_50      4503   12.19 %
BAYES_60       437    1.18 %
BAYES_80       322    0.87 %
BAYES_95       224    0.60 %
BAYES_99      1850    5.01 %
BAYES_999     1647    4.46 %

Delivered:    34896
SpamAssassin: 3071
#!/usr/bin/bash

MAILLOG="/var/log/maillog"

/usr/bin/sa-learn --dump magic
echo ""

/usr/bin/ls -l -h --color=tty -X --group-directories-first 
--time-style=long-iso /var/lib/spamass-milter/.spamassassin/
echo ""

BAYES_00=`grep -c 'spamd: result:.*BAYES_00,' $MAILLOG`
BAYES_05=`grep -c 'spamd: result:.*BAYES_05,' $MAILLOG`
BAYES_20=`grep -c 'spamd: result:.*BAYES_20,' $MAILLOG`
BAYES_40=`grep -c 'spamd: result:.*BAYES_40,' $MAILLOG`
BAYES_50=`grep -c 'spamd: result:.*BAYES_50,' $MAILLOG`
BAYES_60=`grep -c 'spamd: result:.*BAYES_60,' $MAILLOG`
BAYES_80=`grep -c 'spamd: result:.*BAYES_80,' $MAILLOG`
BAYES_95=`grep -c 'spamd: result:.*BAYES_95,' $MAILLOG`
BAYES_99=`grep -c 'spamd: result:.*BAYES_99,' $MAILLOG`
BAYES_999=`grep -c 'spamd: result:.*BAYES_999,' $MAILLOG`

BAYES_TOTAL=`echo 
"$BAYES_00+$BAYES_05+$BAYES_20+$BAYES_40+$BAYES_50+$BAYES_60+$BAYES_80+$BAYES_95+$BAYES_99"
 | bc`

BAYES_00_PCT=`echo "scale=2; ($BAYES_00*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_05_PCT=`echo "scale=2; ($BAYES_05*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_20_PCT=`echo "scale=2; ($BAYES_20*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_40_PCT=`echo "scale=2; ($BAYES_40*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_50_PCT=`echo "scale=2; ($BAYES_50*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_60_PCT=`echo "scale=2; ($BAYES_60*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_80_PCT=`echo "scale=2; ($BAYES_80*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_95_PCT=`echo "scale=2; ($BAYES_95*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_99_PCT=`echo "scale=2; ($BAYES_99*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`
BAYES_999_PCT=`echo "scale=2; ($BAYES_999*100)/$BAYES_TOTAL" | bc | sed 
's/^\./0./'`

echo -e "BAYES_00  `printf \"%*s\" 8 $BAYES_00` `printf \"%*s\" 7 
$BAYES_00_PCT` %"
echo -e "BAYES_05  `printf \"%*s\" 8 $BAYES_05` `printf \"%*s\" 7 
$BAYES_05_PCT` %"
echo -e "BAYES_20  `printf \"%*s\" 8 $BAYES_20` `printf \"%*s\" 7 
$BAYES_20_PCT` %"
echo -e "BAYES_40  `printf \"%*s\" 8 $BAYES_40` `printf \"%*s\" 7 
$BAYES_40_PCT` %"
echo -e "BAYES_50  `printf \"%*s\" 8 $BAYES_50` `printf \"%*s\" 7 
$BAYES_50_PCT` %"
echo -e "BAYES_60  `printf \"%*s\" 8 $BAYES_60` `printf \"%*s\" 7 
$BAYES_60_PCT` %"
echo -e "BAYES_80  `printf \"%*s\" 8 $BAYES_80` `printf \"%*s\" 7 
$BAYES_80_PCT` %"
echo -e "BAYES_95  `printf \"%*s\" 8 $BAYES_95` `printf \"%*s\" 7 
$BAYES_95_PCT` %"
echo -e "BAYES_99  `printf \"%*s\" 8 $BAYES_99` `printf \"%*s\" 7 
$BAYES_99_PCT` %"
echo -e "BAYES_999 `printf \"%*s\" 8 $BAYES_999` `printf \"%*s\" 7 
$BAYES_999_PCT` %"
echo ""

echo "Delivered:    `grep -c 'relay=.*status=sent' $MAILLOG`"
echo "SpamAssassin: `grep -c 'Blocked by SpamAssassin' $MAILLOG`"

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to