Monitor script

This script is used to monitor ProFTPD log and to react at certain events (deletion of the ftp.settings.LOCK_FILENAME).

It is also used at API level in edeposit.amqp (see process_log() and ftp_managerd).

Details of parsing are handled by request_parser.

ftp.monitor._read_stdin()[source]

Generator for reading from standard input in nonblocking mode.

Other ways of reading from stdin in python waits, until the buffer is big enough, or until EOF character is sent.

This functions yields immediately after each line.

ftp.monitor._parse_line(line)[source]

Convert one line from the extended log to dict.

Parameters:line (str) – Line which will be converted.
Returns:dict with timestamp, command, username and path keys.
Return type:dict

Note

Typical line looks like this:

/home/ftp/xex/asd bsd.dat, xex, STOR, 1398351777

Filename may contain , character, so I am rsplitting the line from the end to the beginning.

ftp.monitor.process_log(file_iterator)[source]

Process the extended ProFTPD log.

Parameters:file_iterator (file) – any file-like iterator for reading the log or stdin (see _read_stdin()).
Yields:ImportRequest – with each import.
ftp.monitor.main(filename)[source]

Open filename and start processing it line by line. If filename is none, process lines from stdin.