jenkins-metrics-health 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'jenkins-metrics-health'
@@ -0,0 +1,24 @@
1
+ require "json"
2
+ require "httpclient"
3
+ require "thor"
4
+
5
+ class JenkinsHealth < Thor
6
+ option :url, :aliases => "-u", :required => true, :desc => "Jenkins URL"
7
+ option :key, :aliases => "-k", :required => true, :desc => "Stats api key"
8
+ desc "Jenkins Health Checking", "Automatic health checking for Jenkins. Requires the Jenkins metrics plugin"
9
+ def jenkins
10
+ baseUrl = "#{options[:url]}"
11
+ key = "#{options[:key]}"
12
+ url = baseUrl.chomp("/") + "/metrics/" + key + "/healthcheck"
13
+ http = HTTPClient.new
14
+ json = JSON http.get_content(url)
15
+ checks = ["disk-space", "plugins", "temporary-space", "thread-deadlock"]
16
+ checks.each do |check|
17
+ puts json[check]["message"] if !json[check]["message"].to_s.empty?
18
+ exit(1) if !json[check]["healthy"]
19
+ end
20
+ exit(0)
21
+ end
22
+ default_task :jenkins
23
+ end
24
+ JenkinsHealth.start
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jenkins-metrics-health
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jeff Wong
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-01-21 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Simple Jenkins health status script
15
+ email: awole20@gmail.com
16
+ executables:
17
+ - jenkins-metrics-health
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/jenkins-metrics-health.rb
22
+ - bin/jenkins-metrics-health
23
+ homepage: http://rubygems.org/gems/jenkins-metrics-health
24
+ licenses:
25
+ - MIT
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.23
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Jenkins Health Checks
48
+ test_files: []