5 use vars qw(%DATAFIELDS);
8 use Yaala::Parser::WebserverTools qw(%MONTH_NUMBERS);
9 use Yaala::Data::Persistent qw#init#;
10 use Yaala::Config qw#get_config#;
12 @Yaala::Parser::EXPORT_OK = qw(parse extra %DATAFIELDS);
13 @Yaala::Parser::ISA = ('Exporter');
15 our $LASTDATE = init ('$LASTDATE', 'scalar');
16 our $EXTRA = init ('$EXTRA', 'hash');
18 if (!$$LASTDATE) { $$LASTDATE = 0; }
19 if (!defined ($EXTRA->{'total'})) { $EXTRA->{'total'} = 0; }
20 if (!defined ($EXTRA->{'days'} )) { $EXTRA->{'days'} = {}; }
31 completion_status => 'key',
33 transfer_type => 'key',
34 transfer_time => 'key:numeric',
35 special_action => 'key',
41 # This needs to be done at runtime, since Data uses Setup which relies on
42 # %DATAFIELDS to be defined -octo
43 require Yaala::Data::Core;
44 import Yaala::Data::Core qw#store#;
46 my $VERSION = '$Id: Xferlog.pm,v 1.4 2003/12/07 16:49:56 octo Exp $';
47 print STDERR $/, __FILE__, ": $VERSION" if ($::DEBUG);
54 my @fields = split(m/\s+/, $line);
55 my ($hour, $minute, $second) = split (m/:/, $fields[3]);
57 if (scalar (@fields) != 18)
59 print STDERR $/, __FILE__, ': There were ',
60 scalar (@fields), ' when 18 where expected..'
65 my $tmp = int (sprintf ("%04u%02u%02u%02u%02u%02u",
66 $fields[4], $MONTH_NUMBERS{$fields[1]}, $fields[2],
67 $hour, $minute, $second));
69 if ($tmp < $$LASTDATE)
71 print STDERR $/, __FILE__, ": Skipping.. ($tmp < $$LASTDATE)" if ($::DEBUG & 0x0200);
74 else { $$LASTDATE = $tmp; }
77 my $date = sprintf ("%04u-%02u-%02u", $fields[4], $MONTH_NUMBERS{$fields[1]}, $fields[2]);
79 my $file = $fields[8];
80 my $bytes = $fields[7];
82 my $transfer_time = $fields[5];
84 my $host = $fields[6];
85 my $user = $fields[13];
87 my $transfer_type = ($fields[9] eq 'a' ? 'ascii' : 'binary');
88 my $completion_status = ($fields[17] eq 'c' ? 'complete' : 'incomplete');
91 if ($fields[10] eq '_')
93 $special_action = "none";
95 elsif ($fields[10] eq 'C')
97 $special_action = 'compressed';
99 elsif ($fields[10] eq 'U')
101 $special_action = 'uncompressed';
103 elsif ($fields[10] eq 'T')
105 $special_action = "tar'ed";
109 print STDERR $/, __FILE__, ': Unknown special_action: ',
110 $fields[10] if ($::DEBUG);
115 if ($fields[11] eq 'i')
117 $direction = 'incoming';
119 elsif ($fields[11] eq 'o')
121 $direction = 'outgoing';
123 elsif ($fields[11] eq 'd')
125 $direction = 'deleted';
129 print STDERR $/, __FILE__, ': Unknown direction: ',
130 $fields[11] if ($::DEBUG);
135 if ($fields[12] eq 'a')
137 $access_mode = 'anonymous';
139 elsif ($fields[12] eq 'g')
141 $access_mode = 'guest';
143 elsif ($fields[12] eq 'r')
145 $access_mode = 'real';
149 print STDERR $/, __FILE__, ': Unknown access-method: ',
150 $fields[12] if ($::DEBUG);
155 $EXTRA->{'days'}{$date}++;
158 # 15: authentication-method
159 # 16: authentication-user-id
164 access_mode => $access_mode,
170 completion_status => $completion_status,
171 direction => $direction,
172 transfer_type => $transfer_type,
173 transfer_time => $transfer_time,
174 special_action => $special_action,
184 $::EXTRA->{'Requests Total'} = $EXTRA->{'total'};
186 my $days = scalar (keys (%{$EXTRA->{'days'}}));
188 $::EXTRA->{'Reporting period'} = "$days days";
190 $::EXTRA->{'Average requests per day'} = sprintf ("%.1f", $EXTRA->{'total'} / $days);