Package: logwatch Version: 6.1.2-1 Followup-For: Bug #317913
[CC to [EMAIL PROTECTED] [E-mail has a spam trap! Remove _s__p__a__m] My previous patch had a bug. You could get 'illegal division by 0' in some cases. Attached fixed patch, also added some more lines to ignored lines. -- System Information: Debian Release: 3.1 APT prefers testing APT policy: (500, 'testing') Architecture: i386 (i686) Kernel: Linux 2.4.31-ow1 Locale: LANG=C, LC_CTYPE=pl_PL (charmap=ISO-8859-2) Versions of packages logwatch depends on: ii mailx 1:8.1.2-0.20040524cvs-4 A simple mail user agent ii perl 5.8.4-8 Larry Wall's Practical Extraction -- no debconf information -- Piotrek irc: #debian.pl Mors Drosophilis melanogastribus!
--- pureftpd.org 2005-07-12 10:22:37.000000000 +0200 +++ pureftpd 2005-07-31 13:52:21.000000000 +0200 @@ -28,8 +28,12 @@ $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'}; $ShowLogins = $ENV{'show_logins'}; $ShowLogouts = $ENV{'show_logouts'}; +$ShowDataStats = $ENV{'show_data_stats'}; $ShowDataTransfers = $ENV{'show_data_transfers'}; $ShowNewConnections = $ENV{'show_new_connections'}; +$IgnoreUnmatched = $ENV{'pureftpd_ignore_unmatched'}; +$MinAvgSize = 200*1024 if (!defined ($MinAvgSize = $ENV{'min_avg_file_size'})); +$TopPeopleNr = 3 if (!defined ($TopPeopleNr = $ENV{'top_people_nr'})); $PureShutdown = 0; @@ -38,6 +42,10 @@ ( $ThisLine =~ /last message repeated/ ) or ( $ThisLine =~ /Timeout/) or ( $ThisLine =~ /Can't change directory/) or + ( $ThisLine =~ /File successfully renamed or moved/) or + ( $ThisLine =~ /This is a private system - No anonymous login/) or + ( $ThisLine =~ /Authentication failed for user/) or + ( $ThisLine =~ /Transfer aborted/) or ( $ThisLine =~ /pure-ftpd startup( |) succeeded/) ) { #We don't care about these @@ -51,11 +59,17 @@ $Logins->{$IP}->{$User}++; } elsif (($j,$ConnectionCount,$IP) = ($ThisLine =~ /(.*?)too many connections \((.*?)\) from this ip\: \[(.*?)\]/i )) { $TooManyConnections->{$ConnectionCount}->{$IP}++; - } elsif (($User,$Location,$File,$Direction) = ($ThisLine =~ /\((.*?)\@(.*?)\)\s+\[\w+\]\s+(.*?)\s+(\w+)\s+/)) { - $Direction->{$User}->{$Location}->{$File}++; - } elsif (($User,$Location,$File) = ($ThisLine =~ /\((.*?)\@(.*?)\)\s+\[\w+\]\s+ Deleted ([^ ]+)/)) { - $Direction = "Deleted"; - $Direction->{$User}->{$Location}->{$File}++; + } elsif (($User,$Location,$File,$Direction, $Size, $Speed) = ($ThisLine =~ /\((.*?)\@(.*?)\)\s+\[\w+\]\s+(.*?)\s(downloaded|uploaded)\s+\((\d+) bytes, (.+)KB\/sec\)/)) { + $Transfers->{$Direction}->{$User}->{$Location}->{$File}++; + $Stats->{$Direction}->{"files_count"}++; + $Stats->{$Direction}->{"files_size"} += $Size; + $Stats->{$Direction}->{"people"}->{$User} += $Size; + if ($Size >= $MinAvgSize) { + $Stats->{$Direction}->{"speed"}->{"max"} = $Speed + if ($Stats->{$Direction}->{"speed"}->{"max"} < $Speed); + $Stats->{$Direction}->{"speed"}->{"tmp_size"} += $Size; + $Stats->{$Direction}->{"speed"}->{"tmp_time"} += $Size/($Speed*1024); + } } elsif ($ThisLine =~ m/pure-ftpd shutdown( |) succeeded/) { $PureShutdown++; } else { @@ -100,17 +114,37 @@ } } +if ($ShowDataStats) { + foreach $Direction (keys %{$Stats}) { + print "\nTransfer statistics - $Direction files:\n"; + + print "\t$Stats->{$Direction}->{files_count} $Direction files\n"; + printf "\t%.2f $Direction MB\n", ($Stats->{$Direction}->{'files_size'}/1024)/1024; + if ($Stats->{$Direction}->{speed}) { + print "\t$Stats->{$Direction}->{speed}->{max}KB max speed\n"; + printf "\t%.2fKB/s average speed\n", $Stats->{$Direction}->{'speed'}->{'tmp_size'}/$Stats->{$Direction}->{'speed'}->{'tmp_time'}/1024; + } + @top_people = sort { $Stats->{$Direction}->{'people'}->{$b} <=> $Stats->{$Direction}->{'people'}->{$a} } keys %{ $Stats->{$Direction}->{'people'} }; + if (@top_people) { + print "\tTop $TopPeopleNr people:\n"; + foreach $User (splice @top_people, 0, $TopPeopleNr) { + printf "\t\t%7.2fMB $User\n", $Stats->{$Direction}->{'people'}->{$User}/1024/1024; + } + } + } +} + if ($ShowDataTransfers) { - if (keys %{$Direction}) { - print "\nData Transferred:\n"; - foreach $User (sort {$a cmp $b} keys %{$Direction}) { - foreach $Location (sort {$a cmp $b} keys %{$Direction->{$User}}) { - foreach $Filename (sort {$a cmp $b} keys %{$Direction->{$User}->{$Location}}) { + foreach $Direction (keys %{$Transfers}) { + print "\nData $Direction:\n"; + foreach $User (sort {$a cmp $b} keys %{ $Transfers->{$Direction} }) { + foreach $Location (sort {$a cmp $b} keys %{ $Transfers->{$Direction}->{$User} }) { + foreach $Filename (sort {$a cmp $b} keys %{ $Transfers->{$Direction}->{$User}->{$Location}}) { print "\tUser " . $User . " " . $Direction . " " . $Filename . " from " . $Location . " - ". $Direction->{$User}->{$Location}->{$Filename} . " Time(s)\n"; } } } - } + } } if (keys %SecureAnon) { @@ -129,7 +163,7 @@ } } -if (($#OtherList >= 0) and (not $IngoreUnmatched)){ +if (($#OtherList >= 0) and (not $IgnoreUnmatched)){ print "\n**Unmatched Entries**\n"; print @OtherList; }