class Fluent::OomKillerOutput
Constants
- REGEX1
- REGEX2
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_oomkiller.rb, line 6 def configure(conf) super @logs = {} @is_oomlog = false end
emit(tag, es, chain)
click to toggle source
# File lib/fluent/plugin/out_oomkiller.rb, line 20 def emit(tag, es, chain) if !@logs[:"#{tag}"].instance_of?(Array) @logs[:"#{tag}"] = [] end chain.next es.each {|time, record| make_record_block(tag, time, record) } end
flush_emit(tag, time, record)
click to toggle source
# File lib/fluent/plugin/out_oomkiller.rb, line 67 def flush_emit(tag, time, record) @logs[:"#{tag}"].clear if !@remove_tag_prefix && !@remove_tag_suffix && !@add_tag_prefix && !@add_tag_suffix router.emit(tag, time, record) else _tag = tag.clone filter_record(_tag, time, record) if tag != _tag router.emit(_tag, time, record) else $log.warn "Can not emit message because the tag has not changed. Dropped record #{record}" end end end
make_record_block(tag, time, record)
click to toggle source
# File lib/fluent/plugin/out_oomkiller.rb, line 30 def make_record_block(tag, time, record) if !record.has_key?('message') return end value = record['message'] if @is_oomlog then @logs[:"#{tag}"] << value end if /invoked oom-killer:/ =~ value then @is_oomlog = true @logs[:"#{tag}"] << value elsif /Killed process/ =~ value then @is_oomlog = false parse_record_block(record, tag, time) end end
parse_record_block(syslog_record, tag, time)
click to toggle source
# File lib/fluent/plugin/out_oomkiller.rb, line 53 def parse_record_block(syslog_record, tag, time) record = syslog_record.clone @logs[:"#{tag}"][-1] =~ REGEX2 record['pid'] = $1.to_i record['name'] = $2 record['total_vm_kb'] = $3.to_i record['anon_rss_kb'] = $4.to_i record['file_rss_kb'] = $5.to_i record['raw'] = @logs[:"#{tag}"].map {|m| m.strip}.join("\n") flush_emit(tag, time, record) end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_oomkiller.rb, line 16 def shutdown super end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_oomkiller.rb, line 12 def start super end