Class: PureftpdParser

Inherits:
Parser
  • Object
show all
Defined in:
lib/gl_tail/parsers/pureftpd.rb

Overview

Parser which handles logs from PureFTPD

Instance Attribute Summary

Attributes inherited from Parser

#source

Instance Method Summary collapse

Methods inherited from Parser

#add_activity, #add_event, inherited, #initialize, registry, #server

Constructor Details

This class inherits a constructor from Parser

Instance Method Details

#parse(line) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gl_tail/parsers/pureftpd.rb', line 9

def parse( line )
  _, host, domain, user, date, url, status, size = /^([\d\S.]+) (\S+) (\S+) \[([^\]]+)\] \"(.+?)\" (\d+) ([\S]+)/.match(line).to_a

  if host
    user = host if user == 'ftp'

    method, url = url.split(" ")
    url = method if url.nil?

    if method == "PUT"
      add_activity(:block => 'urls', :name => url, :size => size.to_i, :type => 5)
    else
      add_activity(:block => 'urls', :name => url, :size => size.to_i)
    end
    add_activity(:block => 'sites', :name => server.name, :size => size.to_i) # Size of activity based on size of request
    add_activity(:block => 'users', :name => user, :size => size.to_i)

    add_activity(:block => 'content', :name => 'file')
    add_activity(:block => 'status', :name => status, :type => 3) # don't show a blob
  end
end