class Fluent::Plugin::PortToServiceFilter
Constants
- PORTS
- PROTOCOLS
- SQUERY
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_port_to_service.rb, line 26 def initialize super end
Public Instance Methods
add_service(record)
click to toggle source
# File lib/fluent/plugin/filter_port_to_service.rb, line 57 def add_service(record) # Return if any of the fields are not found. return record unless record[@protocol_key] && record[@port_key] # Reading in parameters from sources aren't always UTF-8. protocol = record[@protocol_key].downcase.encode("UTF-8") port = record[@port_key].to_i # Return if protocol or port is out of range. return record unless PROTOCOLS.include?(protocol) && PORTS.include?(port) service = get_service(protocol, port) if service record[@service_key] = service end record end
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_port_to_service.rb, line 30 def configure(conf) compat_parameters_convert(conf, :inject) super end
filter(tag, time, record)
click to toggle source
# File lib/fluent/plugin/filter_port_to_service.rb, line 47 def filter(tag, time, record) filtered_record = add_service(record) if filtered_record record = filtered_record end record = inject_values_to_record(tag, time, record) record end
get_service(protocol, port)
click to toggle source
# File lib/fluent/plugin/filter_port_to_service.rb, line 75 def get_service(protocol, port) begin log.debug "filter_port_to_service.rb - protocol: #{protocol} class: #{protocol.class} encoding: #{protocol.encoding}" log.debug "filter_port_to_service.rb - port: #{port} class: #{port.class}" stmt = @db.prepare SQUERY stmt.bind_param 1, protocol stmt.bind_param 2, port rs = stmt.execute if row = rs.next service = row["service"] end log.debug "filter_port_to_service.rb - Service: #{service}" rescue ::SQLite3::Exception => e log.error "filter_port_to_service.rb - Error: #{e}" ensure stmt.close if stmt end service end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_port_to_service.rb, line 42 def shutdown @db.close if @db super end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/filter_port_to_service.rb, line 35 def start super log.info "filter_port_to_service.rb - database path: #{@path}" @db = ::SQLite3::Database.new @path @db.results_as_hash = true end