|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
# $Id$
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
# $Log: pureftpd,v $
|
|
Packit |
57988d |
# Revision 1.12 2008/06/30 23:07:51 kirk
|
|
Packit |
57988d |
# fixed copyright holders for files where I know who they should be
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.11 2008/03/24 23:31:26 kirk
|
|
Packit |
57988d |
# added copyright/license notice to each script
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.10 2005/09/29 15:17:32 bjorn
|
|
Packit |
57988d |
# Fixed errant comment
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.9 2005/08/28 22:40:08 bjorn
|
|
Packit |
57988d |
# Patch from Piotr Krukowiecki to prevent illegal division by 0, and
|
|
Packit |
57988d |
# additional ignored lines.
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.8 2005/07/21 05:49:21 bjorn
|
|
Packit |
57988d |
# Allows for spaces in filenames; adds transfer statistics;
|
|
Packit |
57988d |
# ignores deleted/moved/renamed files. Patches from Piotr Krukowieck.
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.7 2005/07/13 16:07:53 mike
|
|
Packit |
57988d |
# Fixed ignoreunmatched typo and set env variable for it -mgt
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.6 2005/02/24 17:08:05 kirk
|
|
Packit |
57988d |
# Applying consolidated patches from Mike Tremaine
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.5 2005/02/16 00:43:28 mgt
|
|
Packit |
57988d |
# Added #vi tag to everything, updated ignore.conf with comments, added emerge and netopia to the tree from Laurent -mgt
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.4 2004/07/29 19:33:29 mgt
|
|
Packit |
57988d |
# Chmod and removed perl call -mgt
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.3 2004/07/10 01:54:35 mgt
|
|
Packit |
57988d |
# sync with kirk -mgt
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
# Revision 1.3 2004/02/03 02:45:26 kirk
|
|
Packit |
57988d |
# Tons of patches, and new 'oidentd' and 'shaperd' filters from
|
|
Packit |
57988d |
# Pawe? Go?aszewski" <blues@ds.pg.gda.pl>
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
#######################################################
|
|
Packit |
57988d |
## Copyright (c) 2008 Chris Smith
|
|
Packit |
57988d |
## Covered under the included MIT/X-Consortium License:
|
|
Packit |
57988d |
## http://www.opensource.org/licenses/mit-license.php
|
|
Packit |
57988d |
## All modifications and contributions by other persons to
|
|
Packit |
57988d |
## this script are assumed to have been donated to the
|
|
Packit |
57988d |
## Logwatch project and thus assume the above copyright
|
|
Packit |
57988d |
## and licensing terms. If you want to make contributions
|
|
Packit |
57988d |
## under your own copyright or a different license this
|
|
Packit |
57988d |
## must be explicitly stated in the contribution an the
|
|
Packit |
57988d |
## Logwatch project reserves the right to not accept such
|
|
Packit |
57988d |
## contributions. If you have made significant
|
|
Packit |
57988d |
## contributions to this script and want to claim
|
|
Packit |
57988d |
## copyright please contact logwatch-devel@lists.sourceforge.net.
|
|
Packit |
57988d |
#########################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
# Written & Maintained by Chris Smith (csmith@squiz.net)
|
|
Packit |
57988d |
##########################################################################
|
|
Packit |
57988d |
|
|
Packit |
57988d |
$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'};
|
|
Packit |
57988d |
$ShowLogins = $ENV{'show_logins'};
|
|
Packit |
57988d |
$ShowLogouts = $ENV{'show_logouts'};
|
|
Packit |
57988d |
$ShowDataStats = $ENV{'show_data_stats'};
|
|
Packit |
57988d |
$ShowDataTransfers = $ENV{'show_data_transfers'};
|
|
Packit |
57988d |
$ShowNewConnections = $ENV{'show_new_connections'};
|
|
Packit |
57988d |
$IgnoreUnmatched = $ENV{'pureftpd_ignore_unmatched'} || 0;
|
|
Packit |
57988d |
$MinAvgSize = 200*1024 if (!defined ($MinAvgSize = $ENV{'min_avg_file_size'}));
|
|
Packit |
57988d |
$TopPeopleNr = 3 if (!defined ($TopPeopleNr = $ENV{'top_people_nr'}));
|
|
Packit |
57988d |
|
|
Packit |
57988d |
$PureShutdown = 0;
|
|
Packit |
57988d |
|
|
Packit |
57988d |
while (defined($ThisLine = <STDIN>)) {
|
|
Packit |
57988d |
if (
|
|
Packit |
57988d |
( $ThisLine =~ /last message repeated/ ) or
|
|
Packit |
57988d |
( $ThisLine =~ /Timeout/) or
|
|
Packit |
57988d |
( $ThisLine =~ /Can't change directory/) or
|
|
Packit |
57988d |
( $ThisLine =~ /File successfully renamed or moved/) or
|
|
Packit |
57988d |
( $ThisLine =~ /This is a private system - No anonymous login/) or
|
|
Packit |
57988d |
( $ThisLine =~ /Authentication failed for user/) or
|
|
Packit |
57988d |
( $ThisLine =~ /Transfer aborted/) or
|
|
Packit |
57988d |
( $ThisLine =~ /pure-ftpd startup( |) succeeded/)
|
|
Packit |
57988d |
) {
|
|
Packit |
57988d |
#We don't care about these
|
|
Packit |
57988d |
} elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)new connection/i )) {
|
|
Packit |
57988d |
$NewConnections{$IP}++;
|
|
Packit |
57988d |
} elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)logout/i )) {
|
|
Packit |
57988d |
$Logouts{$IP}++;
|
|
Packit |
57988d |
} elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)unable to set up secure anonymous ftp/i )) {
|
|
Packit |
57988d |
$SecureAnon{$IP}++;
|
|
Packit |
57988d |
} elsif (($IP,$User) = ($ThisLine =~ /\@(.*?)\)\s*\[info\]\s*(.*?) is now logged in/i )) {
|
|
Packit |
57988d |
$Logins->{$IP}->{$User}++;
|
|
Packit |
57988d |
} elsif (($j,$ConnectionCount,$IP) = ($ThisLine =~ /(.*?)too many connections \((.*?)\) from this ip\: \[(.*?)\]/i )) {
|
|
Packit |
57988d |
$TooManyConnections->{$ConnectionCount}->{$IP}++;
|
|
Packit |
57988d |
} elsif (($User,$Location,$File,$Direction, $Size, $Speed) = ($ThisLine =~ /\((.*?)\@(.*?)\)\s+\[\w+\]\s+(.*?)\s(downloaded|uploaded)\s+\((\d+) bytes, (.+)KB\/sec\)/)) {
|
|
Packit |
57988d |
$Transfers->{$Direction}->{$User}->{$Location}->{$File}++;
|
|
Packit |
57988d |
$Stats->{$Direction}->{"files_count"}++;
|
|
Packit |
57988d |
$Stats->{$Direction}->{"files_size"} += $Size;
|
|
Packit |
57988d |
$Stats->{$Direction}->{"people"}->{$User} += $Size;
|
|
Packit |
57988d |
if ($Size >= $MinAvgSize) {
|
|
Packit |
57988d |
$Stats->{$Direction}->{"speed"}->{"max"} = $Speed
|
|
Packit |
57988d |
if ($Stats->{$Direction}->{"speed"}->{"max"} < $Speed);
|
|
Packit |
57988d |
$Stats->{$Direction}->{"speed"}->{"tmp_size"} += $Size;
|
|
Packit |
57988d |
$Stats->{$Direction}->{"speed"}->{"tmp_time"} += $Size/($Speed*1024);
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
} elsif ($ThisLine =~ m/pure-ftpd shutdown( |) succeeded/) {
|
|
Packit |
57988d |
$PureShutdown++;
|
|
Packit |
57988d |
} else {
|
|
Packit |
57988d |
# Report any unmatched entries...
|
|
Packit |
57988d |
push @OtherList,$ThisLine;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
##########################
|
|
Packit |
57988d |
#
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($PureShutdown > 0) {
|
|
Packit |
57988d |
print "\nPure-ftpd shutdown $PureShutdown Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ShowNewConnections) {
|
|
Packit |
57988d |
if (keys %NewConnections) {
|
|
Packit |
57988d |
print "\nNew Connections:\n";
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %NewConnections) {
|
|
Packit |
57988d |
print "\t" . $Line . " - ". $NewConnections{$Line} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ShowLogins) {
|
|
Packit |
57988d |
if (keys %{$Logins}) {
|
|
Packit |
57988d |
print "\nSuccessful Logins:\n";
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %{$Logins}) {
|
|
Packit |
57988d |
foreach $Detail (sort {$a cmp $b} keys %{$Logins->{$Line}}) {
|
|
Packit |
57988d |
print "\t" . $Detail. " (" . $Line . ") - ". $Logins->{$Line}->{$Detail} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (keys %{$TooManyConnections}) {
|
|
Packit |
57988d |
print "\nToo Many Connections:\n";
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %{$TooManyConnections}) {
|
|
Packit |
57988d |
foreach $Detail (sort {$a cmp $b} keys %{$TooManyConnections->{$Line}}) {
|
|
Packit |
57988d |
print "\t" . $Detail. " (" . $Line . " connections) - ". $TooManyConnections->{$Line}->{$Detail} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ShowDataStats) {
|
|
Packit |
57988d |
foreach $Direction (keys %{$Stats}) {
|
|
Packit |
57988d |
print "\nTransfer statistics - $Direction files:\n";
|
|
Packit |
57988d |
|
|
Packit |
57988d |
print "\t$Stats->{$Direction}->{files_count} $Direction files\n";
|
|
Packit |
57988d |
printf "\t%.2f $Direction MB\n", ($Stats->{$Direction}->{'files_size'}/1024)/1024;
|
|
Packit |
57988d |
if ($Stats->{$Direction}->{speed}) {
|
|
Packit |
57988d |
print "\t$Stats->{$Direction}->{speed}->{max}KB max speed\n";
|
|
Packit |
57988d |
printf "\t%.2fKB/s average speed\n", $Stats->{$Direction}->{'speed'}->{'tmp_size'}/$Stats->{$Direction}->{'speed'}->{'tmp_time'}/1024;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
@top_people = sort { $Stats->{$Direction}->{'people'}->{$b} <=> $Stats->{$Direction}->{'people'}->{$a} } keys %{ $Stats->{$Direction}->{'people'} };
|
|
Packit |
57988d |
if (@top_people) {
|
|
Packit |
57988d |
print "\tTop $TopPeopleNr people:\n";
|
|
Packit |
57988d |
foreach $User (splice @top_people, 0, $TopPeopleNr) {
|
|
Packit |
57988d |
printf "\t\t%7.2fMB $User\n", $Stats->{$Direction}->{'people'}->{$User}/1024/1024;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ShowDataTransfers) {
|
|
Packit |
57988d |
foreach $Direction (keys %{$Transfers}) {
|
|
Packit |
57988d |
print "\nData $Direction:\n";
|
|
Packit |
57988d |
foreach $User (sort {$a cmp $b} keys %{ $Transfers->{$Direction} }) {
|
|
Packit |
57988d |
foreach $Location (sort {$a cmp $b} keys %{ $Transfers->{$Direction}->{$User} }) {
|
|
Packit |
57988d |
foreach $Filename (sort {$a cmp $b} keys %{ $Transfers->{$Direction}->{$User}->{$Location}}) {
|
|
Packit |
57988d |
print "\tUser " . $User . " " . $Direction . " " . $Filename . " from " . $Location . " - ". $Direction->{$User}->{$Location}->{$Filename} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (keys %SecureAnon) {
|
|
Packit |
57988d |
print "\nUnsuccessful Secure Anonymous Connections:\n";
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %SecureAnon) {
|
|
Packit |
57988d |
print "\t" . $Line . " - ". $SecureAnon{$Line} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if ($ShowLogouts) {
|
|
Packit |
57988d |
if (keys %Logouts) {
|
|
Packit |
57988d |
print "\nLogouts:\n";
|
|
Packit |
57988d |
foreach $Line (sort {$a cmp $b} keys %Logouts) {
|
|
Packit |
57988d |
print "\t" . $Line . " - ". $Logouts{$Line} . " Time(s)\n";
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
if (($#OtherList >= 0) and (not $IgnoreUnmatched)){
|
|
Packit |
57988d |
print "\n**Unmatched Entries**\n";
|
|
Packit |
57988d |
print @OtherList;
|
|
Packit |
57988d |
}
|
|
Packit |
57988d |
|
|
Packit |
57988d |
exit(0);
|
|
Packit |
57988d |
|
|
Packit |
57988d |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Packit |
57988d |
# Local Variables:
|
|
Packit |
57988d |
# mode: perl
|
|
Packit |
57988d |
# perl-indent-level: 3
|
|
Packit |
57988d |
# indent-tabs-mode: nil
|
|
Packit |
57988d |
# End:
|