/usr/share/logwatch/scripts/services/pureftpd is in logwatch 7.4.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | #!/usr/bin/perl
##########################################################################
# $Id: pureftpd 150 2013-06-18 22:19:38Z mtremaine $
##########################################################################
# $Log: pureftpd,v $
# Revision 1.12 2008/06/30 23:07:51 kirk
# fixed copyright holders for files where I know who they should be
#
# Revision 1.11 2008/03/24 23:31:26 kirk
# added copyright/license notice to each script
#
# Revision 1.10 2005/09/29 15:17:32 bjorn
# Fixed errant comment
#
# Revision 1.9 2005/08/28 22:40:08 bjorn
# Patch from Piotr Krukowiecki to prevent illegal division by 0, and
# additional ignored lines.
#
# Revision 1.8 2005/07/21 05:49:21 bjorn
# Allows for spaces in filenames; adds transfer statistics;
# ignores deleted/moved/renamed files. Patches from Piotr Krukowieck.
#
# Revision 1.7 2005/07/13 16:07:53 mike
# Fixed ignoreunmatched typo and set env variable for it -mgt
#
# Revision 1.6 2005/02/24 17:08:05 kirk
# Applying consolidated patches from Mike Tremaine
#
# Revision 1.5 2005/02/16 00:43:28 mgt
# Added #vi tag to everything, updated ignore.conf with comments, added emerge and netopia to the tree from Laurent -mgt
#
# Revision 1.4 2004/07/29 19:33:29 mgt
# Chmod and removed perl call -mgt
#
# Revision 1.3 2004/07/10 01:54:35 mgt
# sync with kirk -mgt
#
# Revision 1.3 2004/02/03 02:45:26 kirk
# Tons of patches, and new 'oidentd' and 'shaperd' filters from
# Pawe? Go?aszewski" <blues@ds.pg.gda.pl>
#
##########################################################################
#######################################################
## Copyright (c) 2008 Chris Smith
## Covered under the included MIT/X-Consortium License:
## http://www.opensource.org/licenses/mit-license.php
## All modifications and contributions by other persons to
## this script are assumed to have been donated to the
## Logwatch project and thus assume the above copyright
## and licensing terms. If you want to make contributions
## under your own copyright or a different license this
## must be explicitly stated in the contribution an the
## Logwatch project reserves the right to not accept such
## contributions. If you have made significant
## contributions to this script and want to claim
## copyright please contact logwatch-devel@lists.sourceforge.net.
#########################################################
##########################################################################
# Written & Maintained by Chris Smith (csmith@squiz.net)
##########################################################################
$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'} || 0;
$MinAvgSize = 200*1024 if (!defined ($MinAvgSize = $ENV{'min_avg_file_size'}));
$TopPeopleNr = 3 if (!defined ($TopPeopleNr = $ENV{'top_people_nr'}));
$PureShutdown = 0;
while (defined($ThisLine = <STDIN>)) {
if (
( $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
} elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)new connection/i )) {
$NewConnections{$IP}++;
} elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)logout/i )) {
$Logouts{$IP}++;
} elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)unable to set up secure anonymous ftp/i )) {
$SecureAnon{$IP}++;
} elsif (($IP,$User) = ($ThisLine =~ /\@(.*?)\)\s*\[info\]\s*(.*?) is now logged in/i )) {
$Logins->{$IP}->{$User}++;
} elsif (($j,$ConnectionCount,$IP) = ($ThisLine =~ /(.*?)too many connections \((.*?)\) from this ip\: \[(.*?)\]/i )) {
$TooManyConnections->{$ConnectionCount}->{$IP}++;
} 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 {
# Report any unmatched entries...
push @OtherList,$ThisLine;
}
}
##########################
#
if ($PureShutdown > 0) {
print "\nPure-ftpd shutdown $PureShutdown Time(s)\n";
}
if ($ShowNewConnections) {
if (keys %NewConnections) {
print "\nNew Connections:\n";
foreach $Line (sort {$a cmp $b} keys %NewConnections) {
print "\t" . $Line . " - ". $NewConnections{$Line} . " Time(s)\n";
}
}
}
if ($ShowLogins) {
if (keys %{$Logins}) {
print "\nSuccessful Logins:\n";
foreach $Line (sort {$a cmp $b} keys %{$Logins}) {
foreach $Detail (sort {$a cmp $b} keys %{$Logins->{$Line}}) {
print "\t" . $Detail. " (" . $Line . ") - ". $Logins->{$Line}->{$Detail} . " Time(s)\n";
}
}
}
}
if (keys %{$TooManyConnections}) {
print "\nToo Many Connections:\n";
foreach $Line (sort {$a cmp $b} keys %{$TooManyConnections}) {
foreach $Detail (sort {$a cmp $b} keys %{$TooManyConnections->{$Line}}) {
print "\t" . $Detail. " (" . $Line . " connections) - ". $TooManyConnections->{$Line}->{$Detail} . " Time(s)\n";
}
}
}
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) {
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) {
print "\nUnsuccessful Secure Anonymous Connections:\n";
foreach $Line (sort {$a cmp $b} keys %SecureAnon) {
print "\t" . $Line . " - ". $SecureAnon{$Line} . " Time(s)\n";
}
}
if ($ShowLogouts) {
if (keys %Logouts) {
print "\nLogouts:\n";
foreach $Line (sort {$a cmp $b} keys %Logouts) {
print "\t" . $Line . " - ". $Logouts{$Line} . " Time(s)\n";
}
}
}
if (($#OtherList >= 0) and (not $IgnoreUnmatched)){
print "\n**Unmatched Entries**\n";
print @OtherList;
}
exit(0);
# vi: shiftwidth=3 tabstop=3 syntax=perl et
# Local Variables:
# mode: perl
# perl-indent-level: 3
# indent-tabs-mode: nil
# End:
|