Class: LogStash::Inputs::Udp

Inherits:
Base show all
Defined in:
lib/logstash/inputs/udp.rb

Overview

Read messages as events over the network via udp.

Constant Summary

Constants included from Config::Mixin

Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes inherited from Base

#params, #threadable

Attributes included from Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#tag

Methods included from Config::Mixin

#config_init, included

Methods inherited from Plugin

#eql?, #finished, #finished?, #hash, #inspect, lookup, #reload, #running?, #shutdown, #terminating?, #to_s

Constructor Details

#initialize(params) ⇒ Udp

Returns a new instance of Udp.



26
27
28
29
# File 'lib/logstash/inputs/udp.rb', line 26

def initialize(params)
  super
  BasicSocket.do_not_reverse_lookup = true
end

Instance Method Details

#registerObject



32
33
34
# File 'lib/logstash/inputs/udp.rb', line 32

def register
  @udp = nil
end

#run(output_queue) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/logstash/inputs/udp.rb', line 37

def run(output_queue)
  begin
    # udp server
    udp_listener(output_queue)
  rescue LogStash::ShutdownSignal
    # do nothing, shutdown was requested.
  rescue => e
    @logger.warn("UDP listener died", :exception => e, :backtrace => e.backtrace)
    sleep(5)
    retry
  end # begin
end

#teardownObject



77
78
79
# File 'lib/logstash/inputs/udp.rb', line 77

def teardown
  @udp.close if @udp && !@udp.closed?
end