class Fluent::TextParser::SyslogParserCustom
Constants
- IIB_REGEXP
Expresion regular cuando esta presente el log del IIB
- REGEXP
From existence
TextParser
pattern- REGEXP_WITH_PRI
From in_syslog default pattern
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluentd/plugin/parser_websphere_iib_syslog.rb, line 19 def initialize super @mutex = Mutex.new end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluentd/plugin/parser_websphere_iib_syslog.rb, line 24 def configure(conf) super require 'active_support/time' @timezone_offset = Time.now.formatted_offset @regexp = @with_priority ? Regexp.new(REGEXP_WITH_PRI) : Regexp.new(REGEXP) @iib_regexp = Regexp.new(IIB_REGEXP) @time_parser = TextParser::TimeParser.new(@time_format) end
parse(text) { |nil, nil| ... }
click to toggle source
# File lib/fluentd/plugin/parser_websphere_iib_syslog.rb, line 39 def parse(text) m = @regexp.match(text) #n = @iib_regexp.match(text) unless m if block_given? yield nil, nil return else return nil, nil end end time = nil msg = nil record = {} record["eventype"] = "INFO" record["severity"] = "LOW" record["severity_level"] = 4 record["hostname"] = Socket.gethostname m.names.each { |name| if value = m[name] #$log.info ">>>>>>: #{name}" case name when "priority" record['priority'] = value.to_i when "message" case record["identificador"] when "IIB" #$log.info "message: -> #{value}" msg = value n = @iib_regexp.match(msg) n.names.each { |name| if msg = n[name] #$log.info ">>>>>>: #{name}" record[name] = msg end } if record.has_key?("nodo") record["integration_node"] = record["nodo"].split(".")[0] record["integration_server"] = record["nodo"].split(".")[1] record.delete("nodo") end record["producto"] = record["identificador"] record["ambiente"] = @ambiente record.delete("identificador") record["msgshortname"] = record["msgid"] record["eventype"] = record["msgid"][-1] case record["eventype"] when "E" record["eventype"] = "ERROR" record["severity"] ="HIGH" record["severity_level"] = 5 when "W" record["eventype"] = "WARNING" record["severity"] = "MEDIUM" record["severity_level"] = 5 else record["eventype"] = "INFO" record["severity"] = "LOW" record["severity_level"] = 5 end else record[name] = value end when "timestamp" time = @mutex.synchronize { @time_parser.parse(value.gsub(/ +/, ' ')) } #Se calcula timestmap adicionando timezone timestamp = @mutex.synchronize { DateTime.strptime(value+@timezone_offset,@time_format+'%z').strftime(@output_time_format) } #$log.info "timestamp: #{value+@timezone_offset}" record[name] = timestamp else record[name] = value end end } if @estimate_current_event time ||= Engine.now end if block_given? yield time, record else return time, record end end
patterns()
click to toggle source
# File lib/fluentd/plugin/parser_websphere_iib_syslog.rb, line 35 def patterns {'format' => @regexp, 'time_format' => @time_format, 'subformat' => @iib_regexp} end