Module: Sensu::API::Utilities::TransportInfo

Included in:
Client::HTTPSocket
Defined in:
lib/sensu/api/utilities/transport_info.rb

Instance Method Summary collapse

Instance Method Details

#transport_info {|Hash| ... } ⇒ Object

Retreive the Sensu Transport info, if the API is connected to it, keepalive messages and consumers, and results messages and consumers.

Yields:

  • (Hash)

    passes Transport info to the callback/block.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/sensu/api/utilities/transport_info.rb', line 10

def transport_info
  info = {
    :name => @settings[:transport][:name],
    :keepalives => {
      :messages => nil,
      :consumers => nil
    },
    :results => {
      :messages => nil,
      :consumers => nil
    },
    :connected => false
  }
  if @transport.connected?
    @transport.stats("keepalives") do |stats|
      info[:keepalives] = stats
      if @transport.connected?
        @transport.stats("results") do |stats|
          info[:results] = stats
          info[:connected] = @transport.connected?
          yield(info)
        end
      else
        yield(info)
      end
    end
  else
    yield(info)
  end
end