Sha256: b62353c65176ff01a6b03de937cd59f664f8df458ab074412bbe6cd68c414f13

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

require 'socket'

class Riemann::Babbler::Plugin::ResponderUdp < Riemann::Babbler::Plugin

  def init
    plugin.set_default(:port, opts.riemann.responder_udp_port)
  end

  def process(data, src)
    begin
      report event_from_json(data)
      src.reply "sended\n"
    rescue
      log :error, "Failed to send message: #{data.inspect}"
      src.reply "failed to send: #{data.inspect}\n"
    end    
  end

  def run!
    log :unknown, "Start udp server at #{plugin.port}"
    Socket.udp_server_loop(plugin.port) do |data, src|
      log :debug, "Recived data: #{data.inspect}, from client: #{src.inspect}"
      process(data, src) 
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
riemann-babbler-2.1.1 lib/riemann/babbler/plugins/responder_udp.rb