Module: Sensu::API::Routes::Health
- Includes:
- Utilities::TransportInfo
- Included in:
- Sensu::API::Routes
- Defined in:
- lib/sensu/api/routes/health.rb
Constant Summary collapse
- HEALTH_URI =
/^\/health$/
Instance Method Summary collapse
-
#get_health ⇒ Object
GET /health.
Instance Method Details
#get_health ⇒ Object
GET /health
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 40 41 |
# File 'lib/sensu/api/routes/health.rb', line 12 def get_health @response_content = [] if @redis.connected? && @transport.connected? min_consumers = integer_parameter(@params[:consumers]) = integer_parameter(@params[:messages]) transport_info do |info| if min_consumers if info[:keepalives][:consumers] < min_consumers @response_content << "keepalive consumers (#{info[:keepalives][:consumers]}) less than min_consumers (#{min_consumers})" end if info[:results][:consumers] < min_consumers @response_content << "result consumers (#{info[:results][:consumers]}) less than min_consumers (#{min_consumers})" end end if if info[:keepalives][:messages] > @response_content << "keepalive messages (#{info[:keepalives][:messages]}) greater than max_messages (#{max_messages})" end if info[:results][:messages] > @response_content << "result messages (#{info[:results][:messages]}) greater than max_messages (#{max_messages})" end end @response_content.empty? ? no_content! : precondition_failed! end else @response_content << "not connected to redis" unless @redis.connected? @response_content << "not connected to transport" unless @transport.connected? precondition_failed! end end |