is_it_working-cbeer 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.11
1
+ 1.0.12
@@ -10,6 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.files = `git ls-files`.split("\n")
11
11
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
12
12
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.require_paths = ["lib"]
13
14
  gem.has_rdoc = true
14
15
  gem.rdoc_options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc'
15
16
  gem.extra_rdoc_files = ["README.rdoc"]
@@ -0,0 +1,53 @@
1
+ module IsItWorking
2
+ class RsolrCheck
3
+ def initialize(options={})
4
+ @client = options[:client]
5
+ raise ArgumentError.new(":client not specified") unless @client
6
+ @host = @client.uri
7
+ @alias = options[:alias] || @host
8
+ end
9
+
10
+ def call(status)
11
+ if ping
12
+ status.ok("service active")
13
+ status.info("numDocs: #{luke['numDocs']}")
14
+ status.info("lastModified: #{luke['lastModified']}")
15
+ registry.each do |name, text|
16
+ status.info("#{name} - #{text}")
17
+ end
18
+ else
19
+ status.fail("service down")
20
+ end
21
+ end
22
+
23
+ def luke
24
+ @luke ||= begin
25
+ @client.luke(:show => 'schema', :numTerms => 0)['index']
26
+ rescue
27
+ {}
28
+ end
29
+ end
30
+
31
+ def registry
32
+ @registry ||= begin
33
+ resp = Blacklight.solr.get 'admin/registry.jsp', :params => { :wt => 'xml' }
34
+ doc = Nokogiri::XML resp
35
+ h = {}
36
+ doc.xpath('/solr/*').each do |node|
37
+ next if node.name == "solr-info"
38
+ h[node.name] = node.text
39
+ end
40
+ h
41
+ rescue
42
+ {}
43
+ end
44
+ end
45
+
46
+ def ping
47
+ @client.head("admin/ping").response[:status] == 200
48
+ rescue
49
+ false
50
+ end
51
+ end
52
+ end
53
+
@@ -0,0 +1,48 @@
1
+ module IsItWorking
2
+ class RubydoraCheck
3
+ def initialize(options={})
4
+ @client = options[:client]
5
+ raise ArgumentError.new(":client not specified") unless @client
6
+ @host = @client.client.url
7
+ @timeout = options[:timeout] || 2
8
+ @alias = options[:alias] || @host
9
+ end
10
+
11
+ def call(status)
12
+ begin
13
+ ping
14
+ status.ok("service active")
15
+ ["repositoryName", "repositoryBaseURL", "repositoryVersion"].each do |key|
16
+ status.info("#{key} - #{profile[key]}")
17
+ end
18
+ rescue Errno::ECONNREFUSED
19
+ status.fail("#{@alias} is not accepting connections on port #{@port.inspect}")
20
+ rescue SocketError => e
21
+ status.fail("connection to #{@alias} on port #{@port.inspect} failed with '#{e.message}'")
22
+ rescue Timeout::Error
23
+ status.fail("#{@alias} did not respond on port #{@port.inspect} within #{@timeout} seconds")
24
+ end
25
+ end
26
+
27
+ def profile
28
+ @luke ||= begin
29
+ ActiveFedora::Base.connection_for_pid(0).profile
30
+ rescue
31
+ {}
32
+ end
33
+ end
34
+
35
+ def ping
36
+ timeout(@timeout) do
37
+ s = TCPSocket.new(uri.host, uri.port)
38
+ s.close
39
+ end
40
+ true
41
+ end
42
+
43
+ def uri
44
+ URI(@host)
45
+ end
46
+ end
47
+ end
48
+
data/lib/is_it_working.rb CHANGED
@@ -10,9 +10,11 @@ module IsItWorking
10
10
  # Predefined checks
11
11
  autoload :ActionMailerCheck, File.expand_path("../is_it_working/checks/action_mailer_check.rb", __FILE__)
12
12
  autoload :ActiveRecordCheck, File.expand_path("../is_it_working/checks/active_record_check.rb", __FILE__)
13
+ autoload :RubydoraCheck, File.expand_path("../is_it_working/checks/rubydora_check.rb", __FILE__)
13
14
  autoload :DalliCheck, File.expand_path("../is_it_working/checks/dalli_check.rb", __FILE__)
14
15
  autoload :DirectoryCheck, File.expand_path("../is_it_working/checks/directory_check.rb", __FILE__)
15
16
  autoload :MemcacheCheck, File.expand_path("../is_it_working/checks/memcache_check.rb", __FILE__)
16
17
  autoload :PingCheck, File.expand_path("../is_it_working/checks/ping_check.rb", __FILE__)
18
+ autoload :RsolrCheck, File.expand_path("../is_it_working/checks/rsolr_check.rb", __FILE__)
17
19
  autoload :UrlCheck, File.expand_path("../is_it_working/checks/url_check.rb", __FILE__)
18
- end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_it_working-cbeer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -117,6 +117,8 @@ files:
117
117
  - lib/is_it_working/checks/directory_check.rb
118
118
  - lib/is_it_working/checks/memcache_check.rb
119
119
  - lib/is_it_working/checks/ping_check.rb
120
+ - lib/is_it_working/checks/rsolr_check.rb
121
+ - lib/is_it_working/checks/rubydora_check.rb
120
122
  - lib/is_it_working/checks/url_check.rb
121
123
  - lib/is_it_working/filter.rb
122
124
  - lib/is_it_working/handler.rb
@@ -150,7 +152,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
152
  version: '0'
151
153
  segments:
152
154
  - 0
153
- hash: -2548203515793015154
155
+ hash: -807806617677205946
154
156
  required_rubygems_version: !ruby/object:Gem::Requirement
155
157
  none: false
156
158
  requirements:
@@ -159,7 +161,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
161
  version: '0'
160
162
  segments:
161
163
  - 0
162
- hash: -2548203515793015154
164
+ hash: -807806617677205946
163
165
  requirements: []
164
166
  rubyforge_project:
165
167
  rubygems_version: 1.8.24