Class: PostgreSQLParser
- Defined in:
- lib/gl_tail/parsers/postgresql.rb
Overview
Parser which handles PostgreSQL logs
Instance Attribute Summary
Attributes inherited from Parser
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 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gl_tail/parsers/postgresql.rb', line 9 def parse( line ) # here's an example parser for postgres log files; adjust accordingly for different logfile setups. # # postgresql.conf: # log_line_prefix = '[%d, %t] ' # log_connections = on # log_disconnections = on # log_duration = on # log_statement = 'all' _, database, datetime, activity, description = /^\[(.*), (.* .* .*)\] LOG: ([a-zA-Z0-9\s]*): (.*)/.match(line).to_a if database add_activity(:block => 'database', :name => database, :size => 0.2) else _, datetime, activity, description = /^(.* .* .*) LOG: ([a-zA-Z0-9\s]*): (.*)/.match(line).to_a end if activity activity = 'vacuum' if(description.include?('vacuum') || activity == 'autovacuum') case activity when 'duration' add_activity(:block => 'database', :name => 'duration', :size => description.to_f / 100.0) when 'statement' add_activity(:block => 'database', :name => 'activity', :size => 0.2) when 'connection authorized', 'disconnection' add_activity(:block => 'database', :name => 'login/logout', :size => 0.2) when 'vacuum' add_event(:block => 'database', :name => 'vacuum', :message => description, :update_stats => true, :color => [1.0, 1.0, 0.0, 1.0]) end end end |