Sha256: c5c437ff5047d58d43bd0a5510b5a5ecff920bc7685a4eaeb57dca40bd9ccab8

Contents?: true

Size: 659 Bytes

Versions: 21

Compression:

Stored size: 659 Bytes

Contents

require 'net/http/server'
require 'json'

class Riemann::Responder

  def initialize(port = 55755, logger)
    @port = port
    @logger = logger
    @started_at = Time.now.to_i
  end

  def info
    {
      :version => Riemann::Babbler::VERSION,
      :ruby => "#{RUBY_VERSION}-#{RUBY_PATCHLEVEL}",
      :uptime => Time.now.to_i - @started_at
    }
  end

  def start
    Thread.new {
      @logger.unknown "Start responder 0.0.0.0:#{@port}"
      Net::HTTP::Server.run(:port => @port) do |request, stream|
        @logger.unknown "Responder request: #{request}"
        [200, {'Content-Type' => 'application/json'}, [info.to_json]]
      end
    }
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
riemann-babbler-1.4.0 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9.7 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9.6 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9.5 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9.4 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9.3 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9.1 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.9 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.8 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.7 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.6 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.5 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.4 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.3 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.2 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.1 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.3.0 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.2.9 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.2.8 lib/riemann/babbler/support/responder.rb
riemann-babbler-1.2.7 lib/riemann/babbler/support/responder.rb