NcFTPd::Log::Parse::Xfer - parse NcFTPd xfer logs
use NcFTPd::Log::Parse::Xfer; $parser = NcFTPd::Log::Parse::Xfer->new('xfer.20100101'); while($line = $parser->next) { if($line->{operation} eq 'S') { print 'Upload'; $line->{pathname}; $line->{size}; # ... } } # Check for an error, otherwise it was EOF if($parser->error) { die 'Parsing failed: ' . $parser->error; }
This class is part of the NcFTPd::Log::Parse package. Refer to its documentation for a detailed overview of how this and the other parsers work.
Only NcFTPd::Log::Parse::Xfer specific features are described here.
NcFTPd::Log::Parse::Xfer
Parsed Xfer log entries are returned as hash references whose keys are dependent on the entry's operation. Operations are described below.
operation
Logs created by older versions of NcFTPd may contain less fields than listed here. In these cases the missing field(s) will have a value of undef.
undef
Only the non-obvious fields are described.
chmod entries have an operation code of C
C
time
Date & time the entry occured
process
NcFTPd process ID
Operation code for the type of activity this entry represents, set to C
pathname
mode
Unix style permissions set on pathname by this operation
reserved1
NcFTPd reserved field (empty string)
reserved2
user
email
Anonymous user's password, NcFTPd refers to this as email
host
session_id
delete entries have an operation code of D
D
Operation code for the type of activity this entry represents, set to D
reserved3
link entries have an operation code of L
L
Operation code for the type of activity this entry represents, set to L
source
Path of the file used to create the link
NcFTPd reserved field, always set to to
to
destination
Path of the link
Directory listing entries have an operation code of T
T
Operation code for the type of activity this entry represents, set to T
status
Set to one of the following:
OK ABOR INCOMPLETE PERM NOENT ERROR
pattern
recursion
Set to RECURSIVE if this was a recursive listing, an empty string otherwise
RECURSIVE
Mkdir entries have an operation code of M. The fields are the same as the delete operation's.
M
Rename entries have an operation code of N. The fields are the same as the link operation's.
N
Retrieve entries (downloads) have an operation code of R. The fields are the same as the store operation's.
R
Store entries (uploads) have an operation code of S
S
Operation code for the type of activity this entry represents, set to S
size
The number of bytes transfered
durtaion
Length of the operation in seconds
rate
Kbps transfer rate
suffix
NcFTPd can create archives on the fly. If one was created, this field contains the archive's extention.
See the NcFTPd docs for more info: http://ncftpd.com/ncftpd/doc/xferlog.html#status
type
Binary or ASCII transfer, A or I
A
I
notes
A string of codes providing additional details about the operation. The field can be expanded into something descriptive.
start_of_transfer
Unix timestamp denoting the start of the transfer
starting_size
Size of the file when the transfer started, -1 if unknown
-1
starting_offset
File offset where the transfer began, -1 if unknown
See NcFTPd::Log::Parse for the full documentation.
Create a parser capable of parsing the specified xfer log:
$parser = NcFTPd::Log::Parse::Xfer->new($file, %options)
A parser capable of parsing the specified xfer log.
%options
expand => 1|0
expand => [ 'field1', 'field2', ... ]
Currently only the operation and notes fields can be expanded. 1 will expand all fields 0, the default, will not expand any.
1
0
An entry's operation field is a single character denoting type of log entry (see "XFER LOG ENTRIES"). Use expand to replace this with a meaningful one word description:
expand
# Without expand print "Op: $entry->{operation}" Op: T # With expand print "Op: $entry->{operation}" Op: listing
An entry's notes field can contain a string of multiple character codes. These codes can provide additional details about the operation. Use expand to replace this string of codes with an array reference of meaningfull descriptions:
# Without expand print "Notes: $entry->{notes}" Notes: SfPs # With expand print 'Notes: ', join(', ', @{$entry->{notes}}) Notes: Used sendfile, PASV connection
filter => sub { ... }
See filter's documentation under "new" in NcFTPd::Log::Parse
filter
If a parser cannot be created an error will be raised.
NcFTPd::Log::Parse, NcFTPd::Log::Parse::Session, NcFTPd::Log::Parse::Misc and the NcFTPd log file documentation http://ncftpd.com/ncftpd/doc/misc
Skye Shaw <sshaw AT lucas.cis.temple.edu>
Copyright (C) 2011 Skye Shaw
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install NcFTPd::Log::Parse, copy and paste the appropriate command in to your terminal.
cpanm
cpanm NcFTPd::Log::Parse
CPAN shell
perl -MCPAN -e shell install NcFTPd::Log::Parse
For more information on module installation, please visit the detailed CPAN module installation guide.