Class: JenkinsHealth

Inherits:
Thor
  • Object
show all
Defined in:
lib/jenkins-metrics-health.rb

Instance Method Summary collapse

Instance Method Details

#jenkinsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/jenkins-metrics-health.rb', line 9

def jenkins
  baseUrl = "#{options[:url]}"
  key = "#{options[:key]}"
  url = baseUrl.chomp("/") + "/metrics/" + key + "/healthcheck"
  http = HTTPClient.new
  json = JSON http.get_content(url)
  checks = ["disk-space", "plugins", "temporary-space", "thread-deadlock"]
  checks.each do |check|
    puts json[check]["message"] if !json[check]["message"].to_s.empty?
    exit(1) if !json[check]["healthy"]
  end
  exit(0)
end