class Fluent::Plugin::NetflowipfixInput::UdpListenerThread
Public Class Methods
new(bind, port, udpQueue, tag, log)
click to toggle source
# File lib/fluent/plugin/in_netflowipfix.rb, line 194 def initialize(bind, port, udpQueue, tag, log) @port = port @udpQueue = udpQueue @udp_socket = UDPSocket.new @udp_socket.bind(bind, port) @total = 0 @tag = tag @log = log end
Public Instance Methods
close()
click to toggle source
# File lib/fluent/plugin/in_netflowipfix.rb, line 209 def close @udp_socket.close end
join()
click to toggle source
# File lib/fluent/plugin/in_netflowipfix.rb, line 213 def join @thread.join end
run()
click to toggle source
# File lib/fluent/plugin/in_netflowipfix.rb, line 218 def run nb = 0 loop do msg, sender = @udp_socket.recvfrom(4096) @total = @total + msg.length @log.trace "UdpListenerThread::recvfrom #{msg.length} bytes for #{@total} total on UDP/#{@port}" record = {} record["message"] = msg record["length"] = msg.length record["total"] = @total record["sender"] = sender record["port"] = @port # time = EventTime.new() time = Time.now.getutc @udpQueue << [time, record] # Garbage collection msg = nil sender = nil nb = nb + 1 if nb > 100 GC.start nb = 0 end end end
start()
click to toggle source
# File lib/fluent/plugin/in_netflowipfix.rb, line 204 def start @thread = Thread.new(&method(:run)) @log.trace "UdpListenerThread::start" end