Re: [spamdyke-users] Simple Perl Spam Statistics Contribution
I had to change the script, i attach it below, but first my results. 59983 DENIED_RDNS_MISSING 45597 DENIED_IP_IN_CC_RDNS 24932 DENIED_RBL_MATCH 14527 DENIED_RDNS_RESOLVE 3324ALLOWED 1085TIMEOUT 298 DENIED_GRAYLISTED 297 DENIED_RECIPIENT_BLACKLISTED 42 DENIED_SENDER_NO_MX 3 DENIED_OTHER Allowed: 3324 Denied : 146764 Sum: 150088 % Spam : 97.79% the script doesn't give me some information befor i changed it, i use it with syslog cat /var/log/mail| spamdyke-statistics.pl here is the script i changed to fit my conditionsbtw: the script is realy good, thank you very much #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } foreach my $stat (sort keys %status){ if( $stat =~ m/ALLOWED/){ $allow = $status{$stat}; } else{ $deny += $status{$stat}; } } $spampercentage = sprintf(%.2f, ($deny/($allow+$deny)*100) ); foreach my $key (sort { $status{$b} = $status{$a} || $a cmp $b; } keys %status ){ print $status{$key}\t$key\n; } $sum = ($deny + $allow); print \n; print Allowed: $allow \n; print Denied : $deny \n; print Sum: $sum \n; print % Spam : $spampercentage% \n; carlo Maus Computer C. Jesse Dorfstr. 17 16356 Ahrensfelde Tel. : 030 666 480 30 Fax : 030 666 480 33 Mail : [EMAIL PROTECTED] -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Faris Raouf Gesendet: Samstag, 16. Februar 2008 20:15 An: 'spamdyke users' Betreff: Re: [spamdyke-users] Simple Perl Spam Statistics Contribution That's very useful! Thanks Ken. I'm getting some errors on running it though: Use of uninitialized value in addition (+) at ./spamdyke-stats.pl line 27, line 11167. 11167 16 Use of uninitialized value in concatenation (.) or string at ./spamdyke-stats.pl line 33, line 11167. Allowed: Denied : 11167 % Spam : 100.00 I figured out that it was simply because there are 0 allows in the log I was processing :-) Also I note that my %status=(). Shouldn't there be something in there to generate the per rejection type stats? I'm not getting any printed out. Faris. -Original Message- From: [EMAIL PROTECTED] [mailto:spamdyke-users- [EMAIL PROTECTED] On Behalf Of Ken Schweigert Sent: 15 February 2008 21:18 To: spamdyke users Subject: [spamdyke-users] Simple Perl Spam Statistics Contribution As a small contribution to the project that has saved me and my users from thousands of spam messages, I would like to offer a simple perl script that I wrote that does some simple calculations. I mainly wrote it to see how effective Spamdyke was, what kind of errors spammers were getting, and how much spam actually hit my secondary MX server. I hope someone out there finds it useful, or at least interesting. As with most contributed code, I do not take any responsibility for (mis)use of my code. I'm still learning perl so there may be errors, so please review the code before executing it on your system. It works in my situation and gives me the results I was looking for so hopefully it will do the same for you. Output: [EMAIL PROTECTED] root]# cat /var/log/qmail/smtpd/current | /usr/local/etc/spam-statistics.pl 3775DENIED_RBL_MATCH 3294DENIED_RDNS_MISSING 1780DENIED_RDNS_RESOLVE 932 DENIED_IP_IN_RDNS 425 ALLOWED 124 DENIED_SENDER_NO_MX 25 TIMEOUT 23 DENIED_OTHER 12 ERROR: 3 DENIED_EARLYTALKER Allowed: 425 Denied : 9968 % Spam : 95.91% [EMAIL PROTECTED] root]# Code: [EMAIL PROTECTED] root]# more /usr/local/etc/spam-statistics.pl #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow,$deny,$spampercentage); while(){ my $line = $_; if( /[A-Z].{5,5}/ ){ my ($timestamp,$sdstatus) = split(/\s/ , $line); next if $sdstatus eq
Re: [spamdyke-users] Simple Perl Spam Statistics Contribution
Thanx, this version works with syslog files! BTW I have only 94.11% of spam :) On Mon, 18 Feb 2008 13:03:16 +0100 Carlo Blohm [EMAIL PROTECTED] wrote: I had to change the script, i attach it below, but first my results. 59983 DENIED_RDNS_MISSING 45597 DENIED_IP_IN_CC_RDNS 24932 DENIED_RBL_MATCH 14527 DENIED_RDNS_RESOLVE 3324ALLOWED 1085TIMEOUT 298 DENIED_GRAYLISTED 297 DENIED_RECIPIENT_BLACKLISTED 42 DENIED_SENDER_NO_MX 3 DENIED_OTHER Allowed: 3324 Denied : 146764 Sum: 150088 % Spam : 97.79% the script doesn't give me some information befor i changed it, i use it with syslog cat /var/log/mail| spamdyke-statistics.pl here is the script i changed to fit my conditionsbtw: the script is realy good, thank you very much #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } foreach my $stat (sort keys %status){ if( $stat =~ m/ALLOWED/){ $allow = $status{$stat}; } else{ $deny += $status{$stat}; } } $spampercentage = sprintf(%.2f, ($deny/($allow+$deny)*100) ); foreach my $key (sort { $status{$b} = $status{$a} || $a cmp $b; } keys %status ){ print $status{$key}\t$key\n; } $sum = ($deny + $allow); print \n; print Allowed: $allow \n; print Denied : $deny \n; print Sum: $sum \n; print % Spam : $spampercentage% \n; carlo Maus Computer C. Jesse Dorfstr. 17 16356 Ahrensfelde Tel. : 030 666 480 30 Fax : 030 666 480 33 Mail : [EMAIL PROTECTED] -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Faris Raouf Gesendet: Samstag, 16. Februar 2008 20:15 An: 'spamdyke users' Betreff: Re: [spamdyke-users] Simple Perl Spam Statistics Contribution That's very useful! Thanks Ken. I'm getting some errors on running it though: Use of uninitialized value in addition (+) at ./spamdyke-stats.pl line 27, line 11167. 11167 16 Use of uninitialized value in concatenation (.) or string at ./spamdyke-stats.pl line 33, line 11167. Allowed: Denied : 11167 % Spam : 100.00 I figured out that it was simply because there are 0 allows in the log I was processing :-) Also I note that my %status=(). Shouldn't there be something in there to generate the per rejection type stats? I'm not getting any printed out. Faris. -Original Message- From: [EMAIL PROTECTED] [mailto:spamdyke-users- [EMAIL PROTECTED] On Behalf Of Ken Schweigert Sent: 15 February 2008 21:18 To: spamdyke users Subject: [spamdyke-users] Simple Perl Spam Statistics Contribution As a small contribution to the project that has saved me and my users from thousands of spam messages, I would like to offer a simple perl script that I wrote that does some simple calculations. I mainly wrote it to see how effective Spamdyke was, what kind of errors spammers were getting, and how much spam actually hit my secondary MX server. I hope someone out there finds it useful, or at least interesting. As with most contributed code, I do not take any responsibility for (mis)use of my code. I'm still learning perl so there may be errors, so please review the code before executing it on your system. It works in my situation and gives me the results I was looking for so hopefully it will do the same for you. Output: [EMAIL PROTECTED] root]# cat /var/log/qmail/smtpd/current | /usr/local/etc/spam-statistics.pl 3775DENIED_RBL_MATCH 3294DENIED_RDNS_MISSING 1780DENIED_RDNS_RESOLVE 932 DENIED_IP_IN_RDNS 425 ALLOWED 124 DENIED_SENDER_NO_MX 25 TIMEOUT 23 DENIED_OTHER 12 ERROR: 3 DENIED_EARLYTALKER Allowed: 425 Denied : 9968 % Spam : 95.91% [EMAIL PROTECTED] root]# Code: [EMAIL PROTECTED] root]# more /usr/local/etc/spam-statistics.pl #!/usr/bin/perl -w use diagnostics; use strict; # Usage
Re: [spamdyke-users] Simple Perl Spam Statistics Contribution
Ah yes, I missed the duplicate shell lines too :) About the scripts: Sure, I will assemble them on a web page. I also have Slackware binary package of spamdyke... I will post the url here this week... Carlo Blohm wrote: Hi, Faris Raouf your right, i changed it too sorry Bgsi have copied the first lines of the script twicethe script starts on #!/usr/bin/perl -w use diagnostics; use strict;. ... the exact script is(with the changes of Faris Raouf): #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/mail | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke\[/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } foreach my $stat (sort keys %status){ if( $stat =~ m/ALLOWED/){ $allow = $status{$stat}; } else{ $deny += $status{$stat}; } } $spampercentage = sprintf(%.2f, ($deny/($allow+$deny)*100) ); foreach my $key (sort { $status{$b} = $status{$a} || $a cmp $b; } keys %status ){ print $status{$key}\t$key\n; } $sum = ($deny + $allow); print \n; print Allowed: $allow \n; print Denied : $deny \n; print Sum: $sum \n; print % Spam : $spampercentage% \n; carlo Maus Computer C. Jesse Dorfstr. 17 16356 Ahrensfelde Tel. : 030 666 480 30 Fax : 030 666 480 33 Mail : [EMAIL PROTECTED] -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Faris Raouf Gesendet: Montag, 18. Februar 2008 15:00 An: 'spamdyke users' Betreff: Re: [spamdyke-users] Simple Perl Spam Statistics Contribution Thank you! That solved the problem for me - almost. I was getting results like this: 1594DENIED_RBL_MATCH 1030DENIED_RDNS_MISSING 661 DENIED_RDNS_RESOLVE 74 DENIED_GRAYLISTED 53 ALLOWED 22 TIMEOUT 4 ERROR 3 Clear 1 1203336271.538241 1 1203338534.676240 1 1203340195.814166 (note the bottom three, which are the qmail id refs for emails that have spamdyke in the email address. I had to modify if( m/spamdyke/ ) to if( m/spamdyke\[/ ) - in my logs, all lines generated by spamdyke are like this: Date/time hostname spamdyke[numeric-id] Faris. -Original Message- From: [EMAIL PROTECTED] [mailto:spamdyke-users- [EMAIL PROTECTED] On Behalf Of Carlo Blohm Sent: 18 February 2008 12:03 To: spamdyke users Subject: Re: [spamdyke-users] Simple Perl Spam Statistics Contribution I had to change the script, i attach it below, but first my results. 59983 DENIED_RDNS_MISSING 45597 DENIED_IP_IN_CC_RDNS 24932 DENIED_RBL_MATCH 14527 DENIED_RDNS_RESOLVE 3324ALLOWED 1085TIMEOUT 298 DENIED_GRAYLISTED 297 DENIED_RECIPIENT_BLACKLISTED 42 DENIED_SENDER_NO_MX 3 DENIED_OTHER Allowed: 3324 Denied : 146764 Sum: 150088 % Spam : 97.79% the script doesn't give me some information befor i changed it, i use it with syslog cat /var/log/mail| spamdyke-statistics.pl here is the script i changed to fit my conditionsbtw: the script is realy good, thank you very much #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow, $deny, $spampercentage, $sum); $allow = 0; while(){ my $line = $_; if( m/spamdyke/ ){ my ($a, $b, $c, $d) = split(/:/ , $line); my ($e, $sdstatus) = split(/ /, $d); #print $b\n; next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } foreach my $stat (sort keys %status){ if( $stat =~ m/ALLOWED/){ $allow = $status{$stat}; } else{ $deny += $status{$stat}; } } $spampercentage = sprintf(%.2f, ($deny/($allow+$deny)*100) ); foreach my $key (sort { $status{$b} = $status{$a} || $a cmp $b; } keys %status ){ print $status{$key}\t$key\n; } $sum = ($deny + $allow); print \n; print Allowed: $allow \n
Re: [spamdyke-users] Simple Perl Spam Statistics Contribution
That's very useful! Thanks Ken. I'm getting some errors on running it though: Use of uninitialized value in addition (+) at ./spamdyke-stats.pl line 27, line 11167. 11167 16 Use of uninitialized value in concatenation (.) or string at ./spamdyke-stats.pl line 33, line 11167. Allowed: Denied : 11167 % Spam : 100.00 I figured out that it was simply because there are 0 allows in the log I was processing :-) Also I note that my %status=(). Shouldn't there be something in there to generate the per rejection type stats? I'm not getting any printed out. Faris. -Original Message- From: [EMAIL PROTECTED] [mailto:spamdyke-users- [EMAIL PROTECTED] On Behalf Of Ken Schweigert Sent: 15 February 2008 21:18 To: spamdyke users Subject: [spamdyke-users] Simple Perl Spam Statistics Contribution As a small contribution to the project that has saved me and my users from thousands of spam messages, I would like to offer a simple perl script that I wrote that does some simple calculations. I mainly wrote it to see how effective Spamdyke was, what kind of errors spammers were getting, and how much spam actually hit my secondary MX server. I hope someone out there finds it useful, or at least interesting. As with most contributed code, I do not take any responsibility for (mis)use of my code. I'm still learning perl so there may be errors, so please review the code before executing it on your system. It works in my situation and gives me the results I was looking for so hopefully it will do the same for you. Output: [EMAIL PROTECTED] root]# cat /var/log/qmail/smtpd/current | /usr/local/etc/spam-statistics.pl 3775DENIED_RBL_MATCH 3294DENIED_RDNS_MISSING 1780DENIED_RDNS_RESOLVE 932 DENIED_IP_IN_RDNS 425 ALLOWED 124 DENIED_SENDER_NO_MX 25 TIMEOUT 23 DENIED_OTHER 12 ERROR: 3 DENIED_EARLYTALKER Allowed: 425 Denied : 9968 % Spam : 95.91% [EMAIL PROTECTED] root]# Code: [EMAIL PROTECTED] root]# more /usr/local/etc/spam-statistics.pl #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow,$deny,$spampercentage); while(){ my $line = $_; if( /[A-Z].{5,5}/ ){ my ($timestamp,$sdstatus) = split(/\s/ , $line); next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } foreach my $stat (sort keys %status){ if( $stat =~ m/ALLOWED/){ $allow = $status{$stat}; } else{ $deny += $status{$stat}; } } $spampercentage = sprintf(%.2f, ($deny/($allow+$deny)*100) ); foreach my $key (sort { $status{$b} = $status{$a} || $a cmp $b; } keys %status){ print $status{$key}\t$key\n; } print \n; print Allowed: $allow \n; print Denied : $deny \n; print % Spam : $spampercentage% \n; [EMAIL PROTECTED] root]# Respectfully contributed, ken schweigert -- ___ spamdyke-users mailing list spamdyke-users@spamdyke.org http://www.spamdyke.org/mailman/listinfo/spamdyke-users
Re: [spamdyke-users] Simple Perl Spam Statistics Contribution
On 2/16/2008 [EMAIL PROTECTED] wrote: Allowed: 425 Denied : 9968 % Spam : 95.91% Thank you very much for this, Ken. 96% spam. How sad... Bucky ___ spamdyke-users mailing list spamdyke-users@spamdyke.org http://www.spamdyke.org/mailman/listinfo/spamdyke-users
[spamdyke-users] Simple Perl Spam Statistics Contribution
As a small contribution to the project that has saved me and my users from thousands of spam messages, I would like to offer a simple perl script that I wrote that does some simple calculations. I mainly wrote it to see how effective Spamdyke was, what kind of errors spammers were getting, and how much spam actually hit my secondary MX server. I hope someone out there finds it useful, or at least interesting. As with most contributed code, I do not take any responsibility for (mis)use of my code. I'm still learning perl so there may be errors, so please review the code before executing it on your system. It works in my situation and gives me the results I was looking for so hopefully it will do the same for you. Output: [EMAIL PROTECTED] root]# cat /var/log/qmail/smtpd/current | /usr/local/etc/spam-statistics.pl 3775DENIED_RBL_MATCH 3294DENIED_RDNS_MISSING 1780DENIED_RDNS_RESOLVE 932 DENIED_IP_IN_RDNS 425 ALLOWED 124 DENIED_SENDER_NO_MX 25 TIMEOUT 23 DENIED_OTHER 12 ERROR: 3 DENIED_EARLYTALKER Allowed: 425 Denied : 9968 % Spam : 95.91% [EMAIL PROTECTED] root]# Code: [EMAIL PROTECTED] root]# more /usr/local/etc/spam-statistics.pl #!/usr/bin/perl -w use diagnostics; use strict; # Usage: # cat /var/log/qmail/smtpd/current | ./this_file my %status = ();# hash of status connections my ($allow,$deny,$spampercentage); while(){ my $line = $_; if( /[A-Z].{5,5}/ ){ my ($timestamp,$sdstatus) = split(/\s/ , $line); next if $sdstatus eq CHKUSER; $status{$sdstatus}++; } } foreach my $stat (sort keys %status){ if( $stat =~ m/ALLOWED/){ $allow = $status{$stat}; } else{ $deny += $status{$stat}; } } $spampercentage = sprintf(%.2f, ($deny/($allow+$deny)*100) ); foreach my $key (sort { $status{$b} = $status{$a} || $a cmp $b; } keys %status){ print $status{$key}\t$key\n; } print \n; print Allowed: $allow \n; print Denied : $deny \n; print % Spam : $spampercentage% \n; [EMAIL PROTECTED] root]# Respectfully contributed, ken schweigert -- Have a nice day ... unless you've made other plans. ___ spamdyke-users mailing list spamdyke-users@spamdyke.org http://www.spamdyke.org/mailman/listinfo/spamdyke-users