Method: What::Sup#fetch_status

Defined in:
lib/what/sup.rb

#fetch_status(host, port = '9428') ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/what/sup.rb', line 32

def fetch_status(host, port='9428')      
  status = { 'host' => host, 'health' => 'unknown', 'oks' => [], 'warnings' => [], 'alerts' => [] }
  begin
    response = JSON.parse(Net::HTTP.get(host, '/', port))
    #status['details'] = response['details']
    response['details'].each do |d|
      if LEVELS.index(d['health']) > LEVELS.index(status['health'])
        status['health'] = d['health']
      end
      status["#{d['health']}s"] << [d['type'], d['details']]
    end
  rescue
  end
  status
end