Koozali.org: home of the SME Server

Count LearnAsSpam

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Count LearnAsSpam
« on: January 16, 2016, 03:54:41 PM »
I created a script to see if my users are using LearnAsSpam folder:
Code: [Select]

[root@andorinha ~]# cat ContaEmailsLearnAsSpam.sh

echo
echo
echo

pushd /home/e-smith/files/users/ >>/dev/nul
for u in `ls | grep -v admin`
do
  emails=`ls -1 $u/Maildir/.LearnAsSpam/cur |wc -l`
  if  [[ $emails > 0 ]];   then
     echo "Usuario: $u          LearnAsSpam: $emails"
  fi
done
popd >>/dev/nul
echo


And this is today report:
[root@andorinha ~]# ./ContaEmailsLearnAsSpam.sh



Usuario: gcontratos     LearnAsSpam: 412
Usuario: gustavo        LearnAsSpam: 802
Usuario: michel         LearnAsSpam: 228
Usuario: sec_dir        LearnAsSpam: 10
Usuario: tecnico2       LearnAsSpam: 1
Usuario: vendas02       LearnAsSpam: 123


I think some directories were not analised. I doubt "gustavo" received  802 spam in only a daY.
How can I run script by hand and see errors ?

Thanks

Jáder
...

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Count LearnAsSpam
« Reply #1 on: January 16, 2016, 04:19:40 PM »
Is the LearnAsSpam cron job running?  If so, are you sending the output to /dev/null, or is it being emailed to root?

Do the counts from your script change to zero if you run /usr/bin/LearnAsSpam.pl manually?

Does sa-learn --dump magic indicate that your system is learning spam (does the value for "nspam" go up)?

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Re: Count LearnAsSpam
« Reply #2 on: January 17, 2016, 01:29:51 AM »
Hi

I do not have  /usr/bin/LearnAsSpam.pl . Should it be installed with contrib?

Code: [Select]
[root@andorinha ~]# locate -i learnasspam|grep -v users
/etc/e-smith/skel/user/Maildir/.LearnAsSpam
/etc/e-smith/skel/user/Maildir/.LearnAsSpam/cur
/etc/e-smith/skel/user/Maildir/.LearnAsSpam/new
/etc/e-smith/skel/user/Maildir/.LearnAsSpam/tmp
/home/e-smith/files/BackupConfig/Utilitarios/ContaEmailsLearnAsSpam.sh
/root/ContaEmailsLearnAsSpam.sh

And yes, sa-learn numbers are increasing:

Code: [Select]
[root@andorinha ~]# sa-learn --dump magic
0.000          0          3          0  non-token data: bayes db version
0.000          0        647          0  non-token data: nspam
0.000          0       1256          0  non-token data: nham
0.000          0     120916          0  non-token data: ntokens
0.000          0 1451907781          0  non-token data: oldest atime
0.000          0 1452989630          0  non-token data: newest atime
0.000          0 1452988008          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
[root@andorinha ~]#
...

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Re: Count LearnAsSpam
« Reply #3 on: January 17, 2016, 02:23:44 AM »
ohhh...just discovered that those two scripts are not included on SME!
http://bugs.contribs.org/show_bug.cgi?id=1701#c25

So I'd like to ask about what version is SME9 aproved to install and process those e-mail to SA learn.

Regards

Jáder
BTW: I think we need to update wiki pages about these scripts (LearnAsSpam.pl and LearnAsHam.pl)
...

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Count LearnAsSpam
« Reply #4 on: January 17, 2016, 05:00:34 PM »
Did you start with the Learn contrib, or did you setup Bayesian auto-learning manually?

Here's an old post about the Learn contrib: http://forums.contribs.org/index.php?topic=47762.0

Here you go; just for you ;-)
LearnAsSpam / LearnAs Ham (spam/ham training)

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Re: Count LearnAsSpam
« Reply #5 on: January 17, 2016, 11:35:51 PM »
I've started with AutoLearning from wiki e-mail page .

Thanks for wiki updates, but I think it lacks directions about where to put those downloaded files (.pl .cron).
BTW I prefer to create just one .cron file in cron.daily, so learn is just once a day.

edit: remove comment about missing info where to put files. :$ Sorry!
« Last Edit: January 17, 2016, 11:37:30 PM by jader »
...

Offline Jáder

  • *
  • 1,099
  • +0/-0
    • LinuxFacil
Re: Count LearnAsSpam
« Reply #6 on: January 21, 2016, 12:01:44 AM »
Here is a new version of my script... if someone care:

Code: [Select]
[root@andorinha ~]# cat ContaLearn.sh

echo
echo
date
declare -i tspam
declare -i tham

pushd /home/e-smith/files/users/ >>/dev/nul
for u in `ls | grep -v admin`
do
  spam=`ls -1 $u/Maildir/.LearnAsSpam/cur |wc -l`
  ham=`ls -1 $u/Maildir/.LearnAsHam/cur |wc -l`
  if  [[ $spam > 0 ]] || [[ $ham > 0 ]];   then
     echo "Usuario: $u    LearnAsSpam: $spam    LearnAsHam: $ham"
  fi
  tspam=$tspam+$spam
  tham=$tham+$ham
done
echo "-----------------------------------------------------------------------------"
echo "  Total:            Spam: $tspam Ham: $tham "
popd >>/dev/nul
echo
Now it counts HAM and SPAM to be learned and sum them at end! ;)
...

guest22

Re: Count LearnAsSpam
« Reply #7 on: January 21, 2016, 05:06:15 AM »
Anything we should (better) document on the wiki?