NcFTPd::Log::Parse::Session - parse NcFTPd session logs
use NcFTPd::Log::Parse::Session; $parser = NcFTPd::Log::Parse::Session->new('sess.20100101'); while($line = $parser->next) { $line->{user}; $line->{successful_downloads}; $line->{failed_uploads}; # ... } } # 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::Session specific features are described here.
NcFTPd::Log::Parse::Session
Unless noted, fields in a session log contain summaries of a user's activity (or lack of activity). Only the non-obvious fields are described here.
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
time
Date & time the connection was closed
process
NcFTPd process ID
user
Username provided for this session. Could contain the value REFUSED or DENIED. See the NcFTPd docs for more details.
REFUSED
DENIED
email
host
session_time
The total amount of time the user was logged in, given in seconds
time_between_commands
Given in seconds
bytes_retrieved
bytes_stored
number_of_commands
Number of commands the user sent
retrieves
stores
chdirs
nlists
lists
types
Number of times the user changed the transfer type (i.e binary or ASCII)
port_pasv
Number of PORT and PASV commands
PORT
PASV
pwd
size
mdtm
Number of file modification time requests
site
logins
Successful logins
failed_data_connections
last_transfer_result
The result of the last transfer for this session, set to one of the following:
OK ABOR INCOMPLETE PERM NOENT ERROR
See the NcFTPd docs for more info: http://ncftpd.com/ncftpd/doc/xferlog.html#status
successful_downloads
failed_downloads
successful_uploads
failed_uploads
successful_listings
failed_listings
close_code
The reason the connection was closed, See "CLOSE CODES".
This field can be expand to something more descriptive. See expand.
expand
session_id
Integers describing why the connection was closed. Refer to the NcFTPd documentation: http://ncftpd.com/ncftpd/doc/sesslog.html#CloseCodes
See NcFTPd::Log::Parse for the full documentation.
Create a parser capable of parsing the specified session log:
$parser = NcFTPd::Log::Parse::Session->new($file, %options)
A parser capable of parsing the specified session log.
%options
expand => 1|0
expand => [ 'field1', 'field2', ... ]
Currently only the close_code field can be expanded. 1 will expand all fields 0, the default, will not expand any.
1
0
By default close_code contains an integer value denoting the reason the connection was closed. Use expand to replace these integers with a meaningful description:
# Without expand print "Closed because: $entry->{close_code}" # Closed because: 2 # With expand print "Closed because: $entry->{close_code}" # Closed because: Miscellaneous error
If a parser cannot be created an error will be raised.
NcFTPd::Log::Parse, NcFTPd::Log::Parse::Xfer, 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.