Class: QmailParser

Inherits:
Parser show all
Defined in:
lib/gl_tail/parsers/qmail.rb

Overview

Parser which handles qmail logs

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/qmail.rb', line 9

def parse( line )
  if line.include?(' logged in from ')
    _, user, host, ip = /: User \'([^']+)\' of \'([^']+)\' logged in from (\d+.\d+.\d+.\d+)/.match(line).to_a
    if host
      add_activity(:block => 'logins', :name => user+'@'+host, :size => 0.05)
      add_activity(:block => 'sites', :name => server.name, :size => 0.05)
    end
  elsif line.include?(' to local ')
    _, prefix, host = / to local ([^@]+)@(.*)/.match(line).to_a
    if host
      add_activity(:block => 'mail to', :name => host, :size => 0.05)
      add_activity(:block => 'sites', :name => server.name, :size => 0.05)
    end
  elsif line.include?(' to remote ')
    _, prefix, host = / to remote ([^@]+)@(.*)/.match(line).to_a
    if host
      add_activity(:block => 'mail from', :name => host, :size => 0.05)
      add_activity(:block => 'sites', :name => server.name, :size => 0.05)
    end
  end
end