okcomputer 0.6.0 → 0.7.0
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.
- checksums.yaml +4 -4
- data/README.markdown +50 -17
- data/Rakefile +0 -3
- data/app/controllers/ok_computer/ok_computer_controller.rb +55 -0
- data/config/routes.rb +11 -4
- data/lib/{okcomputer → ok_computer}/built_in_checks/active_record_check.rb +1 -1
- data/lib/ok_computer/built_in_checks/cache_check.rb +32 -0
- data/lib/{okcomputer → ok_computer}/built_in_checks/default_check.rb +1 -1
- data/lib/{okcomputer → ok_computer}/built_in_checks/delayed_job_backed_up_check.rb +6 -2
- data/lib/{okcomputer → ok_computer}/built_in_checks/mongoid_check.rb +6 -3
- data/lib/{okcomputer → ok_computer}/built_in_checks/resque_backed_up_check.rb +1 -1
- data/lib/{okcomputer → ok_computer}/built_in_checks/resque_down_check.rb +1 -1
- data/lib/{okcomputer → ok_computer}/built_in_checks/ruby_version_check.rb +1 -1
- data/lib/{okcomputer → ok_computer}/built_in_checks/size_threshold_check.rb +1 -1
- data/lib/{okcomputer → ok_computer}/check.rb +1 -1
- data/lib/{okcomputer → ok_computer}/check_collection.rb +1 -1
- data/lib/{okcomputer → ok_computer}/configuration.rb +19 -32
- data/lib/ok_computer/engine.rb +5 -0
- data/lib/{okcomputer → ok_computer}/registry.rb +4 -4
- data/lib/ok_computer/version.rb +3 -0
- data/lib/okcomputer.rb +20 -16
- metadata +24 -20
- data/app/controllers/ok_computer_controller.rb +0 -48
- data/lib/okcomputer/engine.rb +0 -7
- data/lib/okcomputer/version.rb +0 -3
- data/lib/tasks/okcomputer_tasks.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a38df5e1069db78fedda2655d6b741d26e2df89
|
4
|
+
data.tar.gz: 71173a3054b80f1eb1b63c0f41881543affa4184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62a0d7a18575982c768012957c05482a2ad1c159741aef7de3c5349bc0bf97b375745ea718b3ffecbfeb1c5f374d1cad8bbd94f37195882d5f901259257d6833
|
7
|
+
data.tar.gz: 429ab7284ea63dcd63eb8959712d0953bdf708cb85986562d7d7638aa2780746bceb037f1cdcfc581bb9c47aa9f430d5970cef126dadc66bd613ad8780e69f51
|
data/README.markdown
CHANGED
@@ -40,12 +40,12 @@ We also include a MongoidCheck, but do not register it. If you use Mongoid,
|
|
40
40
|
replace the default ActiveRecord check like so:
|
41
41
|
|
42
42
|
```ruby
|
43
|
-
|
43
|
+
OkComputer::Registry.register "database", OkComputer::MongoidCheck.new
|
44
44
|
```
|
45
45
|
|
46
46
|
If you use another database adapter, see Registering Custom Checks below to
|
47
47
|
build your own database check and register it with the name "database" to
|
48
|
-
replace the built-in check, or use `
|
48
|
+
replace the built-in check, or use `OkComputer::Registry.deregister "database"`
|
49
49
|
to stop checking your database altogether.
|
50
50
|
|
51
51
|
### Requiring Authentication
|
@@ -54,7 +54,29 @@ Optionally require HTTP Basic authentication to view the results of checks in an
|
|
54
54
|
|
55
55
|
```ruby
|
56
56
|
# config/initializers/okcomputer.rb
|
57
|
-
|
57
|
+
OkComputer.require_authentication("username", "password")
|
58
|
+
```
|
59
|
+
|
60
|
+
### Changing the OkComputer Route
|
61
|
+
|
62
|
+
By default, OkComputer routes are mounted at `/okcomputer`. If you'd like to use an alternate route,
|
63
|
+
you can configure it with:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
# config/initializers/okcomputer.rb
|
67
|
+
OkComputer.mount_at = 'health_checks' # mounts at /health_checks
|
68
|
+
```
|
69
|
+
|
70
|
+
For more control of adding OkComputer to your routes, set `OkComputer.mount_at
|
71
|
+
= false` to disable automatic mounting, and you can manually mount the engine
|
72
|
+
in your `routes.rb`.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
# config/initializers/okcomputer.rb
|
76
|
+
OkComputer.mount_at = false
|
77
|
+
|
78
|
+
# config/routes.rb, at any priority that suits you
|
79
|
+
mount OkComputer::Engine, at: "/custom_path"
|
58
80
|
```
|
59
81
|
|
60
82
|
### Registering Additional Checks
|
@@ -63,20 +85,20 @@ Register additional checks in an initializer, like so:
|
|
63
85
|
|
64
86
|
```ruby
|
65
87
|
# config/initializers/okcomputer.rb
|
66
|
-
|
67
|
-
|
88
|
+
OkComputer::Registry.register "resque_down", OkComputer::ResqueDownCheck.new
|
89
|
+
OkComputer::Registry.register "resque_backed_up", OkComputer::ResqueBackedUpCheck.new("critical", 100)
|
68
90
|
```
|
69
91
|
|
70
92
|
### Registering Custom Checks
|
71
93
|
|
72
94
|
The simplest way to register a check unique to your application is to subclass
|
73
|
-
|
95
|
+
OkComputer::Check and implement your own `#check` method, which sets the
|
74
96
|
display message with `mark_message`, and calls `mark_failure` if anything is
|
75
97
|
wrong.
|
76
98
|
|
77
99
|
```ruby
|
78
100
|
# config/initializers/okcomputer.rb
|
79
|
-
class MyCustomCheck <
|
101
|
+
class MyCustomCheck < OkComputer::Check
|
80
102
|
def check
|
81
103
|
if rand(10).even?
|
82
104
|
mark_message "Even is great!"
|
@@ -87,7 +109,7 @@ class MyCustomCheck < OKComputer::Check
|
|
87
109
|
end
|
88
110
|
end
|
89
111
|
|
90
|
-
|
112
|
+
OkComputer::Registry.register "check_for_odds", MyCustomCheck.new
|
91
113
|
```
|
92
114
|
|
93
115
|
## Performing Checks
|
@@ -102,19 +124,22 @@ Checks are available as plain text (by default) or JSON by appending .json, e.g.
|
|
102
124
|
|
103
125
|
## OkComputer NewRelic Ignore
|
104
126
|
|
105
|
-
If
|
106
|
-
|
107
|
-
|
127
|
+
If NewRelic is installed, OkComputer automatically disables NewRelic monitoring for uptime checks,
|
128
|
+
as it will start to artificially bring your request time down.
|
129
|
+
|
130
|
+
If you'd like to intentionally count OkComputer requests in your NewRelic analytics, set:
|
131
|
+
|
132
|
+
```
|
133
|
+
# config/initializers/okcomputer.rb
|
134
|
+
OkComputer.analytics_ignore = false
|
135
|
+
```
|
108
136
|
|
109
137
|
## Deprecations and Breaking Changes
|
110
138
|
|
111
|
-
####
|
139
|
+
#### Namespace change from `OKComputer` to `OkComputer`
|
112
140
|
|
113
|
-
|
114
|
-
|
115
|
-
define a #check method which calls `mark_failure` and `mark_message` as
|
116
|
-
appropriate. In the meantime, OKComputer displays a warning and uses the result
|
117
|
-
of the #call method as the message.
|
141
|
+
OkComputer has changed its namespace from `OKComputer` (uppercase K) to `OkComputer` (lowercase k)
|
142
|
+
as of version 0.7.0. Please update your configuration accordingly.
|
118
143
|
|
119
144
|
#### Breaking Changes of JSON Output
|
120
145
|
|
@@ -145,6 +170,14 @@ example:
|
|
145
170
|
{"check": "result", "other": "result"}
|
146
171
|
```
|
147
172
|
|
173
|
+
#### Deprecation of Check#call
|
174
|
+
|
175
|
+
Versions before 0.2.0 implemented a "#call" method which returned the message.
|
176
|
+
This has been deprecated and will be removed in a future version. Please
|
177
|
+
define a #check method which calls `mark_failure` and `mark_message` as
|
178
|
+
appropriate. In the meantime, OkComputer displays a warning and uses the result
|
179
|
+
of the #call method as the message.
|
180
|
+
|
148
181
|
## Contributing
|
149
182
|
|
150
183
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -5,9 +5,6 @@ rescue LoadError
|
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
7
|
|
8
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
-
load 'rails/tasks/engine.rake'
|
10
|
-
|
11
8
|
Bundler::GemHelper.install_tasks
|
12
9
|
|
13
10
|
task :default => :spec
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module OkComputer
|
2
|
+
class OkComputerController < ActionController::Base
|
3
|
+
layout nil
|
4
|
+
respond_to :text, :html, :json
|
5
|
+
|
6
|
+
before_filter :authenticate
|
7
|
+
|
8
|
+
if OkComputer.analytics_ignore && defined?(NewRelic::Agent::Instrumentation::ControllerInstrumentation)
|
9
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
10
|
+
newrelic_ignore if respond_to?(:newrelic_ignore)
|
11
|
+
end
|
12
|
+
|
13
|
+
rescue_from OkComputer::Registry::CheckNotFound do |e|
|
14
|
+
respond_to do |f|
|
15
|
+
f.any(:text, :html) { render text: e.message, status: :not_found }
|
16
|
+
f.json { render json: { error: e.message }, status: :not_found }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def index
|
21
|
+
checks = OkComputer::Registry.all
|
22
|
+
checks.run
|
23
|
+
|
24
|
+
respond checks, status_code(checks)
|
25
|
+
end
|
26
|
+
|
27
|
+
def show
|
28
|
+
check = OkComputer::Registry.fetch(params[:check])
|
29
|
+
check.run
|
30
|
+
|
31
|
+
respond check, status_code(check)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def respond(data, status)
|
37
|
+
respond_to do |format|
|
38
|
+
format.any(:text, :html) { render text: data, status: status }
|
39
|
+
format.json { render json: data, status: status }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def status_code(check)
|
44
|
+
check.success? ? :ok : :error
|
45
|
+
end
|
46
|
+
|
47
|
+
def authenticate
|
48
|
+
if OkComputer.requires_authentication?(params)
|
49
|
+
authenticate_or_request_with_http_basic do |username, password|
|
50
|
+
OkComputer.authenticate(username, password)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
match "/
|
4
|
-
match "
|
1
|
+
OkComputer::Engine.routes.draw do
|
2
|
+
root to: "ok_computer#show", defaults: {check: "default"}, via: [:get, :options]
|
3
|
+
match "/all" => "ok_computer#index", via: [:get, :options]
|
4
|
+
match "/:check" => "ok_computer#show", via: [:get, :options]
|
5
|
+
end
|
6
|
+
|
7
|
+
if OkComputer.mount_at
|
8
|
+
# prepend sets at a higher priority than "catchall" routes
|
9
|
+
Rails.application.routes.prepend do
|
10
|
+
mount OkComputer::Engine => OkComputer.mount_at, as: "okcomputer"
|
11
|
+
end
|
5
12
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module OkComputer
|
2
|
+
class CacheCheck < Check
|
3
|
+
|
4
|
+
ConnectionFailed = Class.new(StandardError)
|
5
|
+
|
6
|
+
# Public: Check whether the cache is active
|
7
|
+
def check
|
8
|
+
mark_message "Cache is available (#{stats})"
|
9
|
+
rescue ConnectionFailed => e
|
10
|
+
mark_failure
|
11
|
+
mark_message "Error: '#{e}'"
|
12
|
+
end
|
13
|
+
|
14
|
+
# Public: Outputs stats string for cache
|
15
|
+
def stats
|
16
|
+
stats = Rails.cache.stats
|
17
|
+
host = stats.select{|k,v| k =~ Regexp.new(Socket.gethostname) }.values[0]
|
18
|
+
mem_used = to_megabytes host['bytes']
|
19
|
+
mem_max = to_megabytes host['limit_maxbytes']
|
20
|
+
return "#{mem_used} / #{mem_max} MB, #{stats.count - 1} peers"
|
21
|
+
rescue => e
|
22
|
+
raise ConnectionFailed, e
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Private: Convert bytes to megabytes
|
28
|
+
def to_megabytes(bytes)
|
29
|
+
bytes.to_i / (1024 * 1024)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module OkComputer
|
2
2
|
class DelayedJobBackedUpCheck < SizeThresholdCheck
|
3
3
|
attr_accessor :priority
|
4
4
|
attr_accessor :threshold
|
@@ -22,7 +22,11 @@ module OKComputer
|
|
22
22
|
|
23
23
|
# Public: How many delayed jobs are pending within the given priority
|
24
24
|
def size
|
25
|
-
Delayed::Job
|
25
|
+
if defined?(::Delayed::Backend::Mongoid::Job) && Delayed::Worker.backend == Delayed::Backend::Mongoid::Job
|
26
|
+
Delayed::Job.lte(priority: priority).where(:locked_at => nil, :last_error => nil).count
|
27
|
+
else
|
28
|
+
Delayed::Job.where("priority <= ?", priority).where(:locked_at => nil, :last_error => nil).count
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module OkComputer
|
2
2
|
class MongoidCheck < Check
|
3
3
|
# Public: Return the status of the mongodb
|
4
4
|
def check
|
@@ -12,7 +12,11 @@ module OKComputer
|
|
12
12
|
#
|
13
13
|
# Returns a hash with the status of the db
|
14
14
|
def mongodb_stats
|
15
|
-
Mongoid.
|
15
|
+
if Mongoid.respond_to?(:default_session)
|
16
|
+
Mongoid.default_session.command(dbStats: 1) # Mongoid 3+
|
17
|
+
else
|
18
|
+
Mongoid.database.stats # Mongoid 2
|
19
|
+
end
|
16
20
|
rescue => e
|
17
21
|
raise ConnectionFailed, e
|
18
22
|
end
|
@@ -27,4 +31,3 @@ module OKComputer
|
|
27
31
|
ConnectionFailed = Class.new(StandardError)
|
28
32
|
end
|
29
33
|
end
|
30
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module OkComputer
|
2
2
|
# Public: Configure HTTP Basic authentication
|
3
3
|
#
|
4
4
|
# username - Username required to view checks
|
@@ -8,10 +8,10 @@ module OKComputer
|
|
8
8
|
#
|
9
9
|
# Examples:
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# OkComputer.require_authentication("foo", "bar")
|
12
12
|
# # => Require authentication with foo:bar for all checks
|
13
13
|
#
|
14
|
-
#
|
14
|
+
# OkComputer.require_authentication("foo", "bar", except: %w(default nonsecret))
|
15
15
|
# # => Require authentication with foo:bar for all checks except the checks named "default" and "nonsecret"
|
16
16
|
def self.require_authentication(username, password, options = {})
|
17
17
|
self.username = username
|
@@ -31,7 +31,7 @@ module OKComputer
|
|
31
31
|
username == username_try && password == password_try
|
32
32
|
end
|
33
33
|
|
34
|
-
# Public: Whether
|
34
|
+
# Public: Whether OkComputer is configured to require authentication
|
35
35
|
#
|
36
36
|
# Returns a Boolean
|
37
37
|
def self.requires_authentication?(params={})
|
@@ -40,41 +40,28 @@ module OKComputer
|
|
40
40
|
username && password
|
41
41
|
end
|
42
42
|
|
43
|
-
#
|
43
|
+
# Public: The route to automatically mount the OkComputer engine. Setting to false
|
44
|
+
# prevents OkComputer from automatically mounting itself.
|
45
|
+
mattr_accessor :mount_at
|
46
|
+
self.mount_at = 'okcomputer'
|
44
47
|
|
45
|
-
#
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
private_class_method :username
|
48
|
+
# Public: Option to disable third-party app performance tools (.e.g NewRelic) from counting OkComputer routes towards their total.
|
49
|
+
mattr_accessor :analytics_ignore
|
50
|
+
self.analytics_ignore = true
|
50
51
|
|
51
|
-
# Private:
|
52
|
-
|
53
|
-
|
54
|
-
end
|
52
|
+
# Private: The username for access to checks
|
53
|
+
mattr_accessor :username
|
54
|
+
private_class_method :username
|
55
55
|
private_class_method :username=
|
56
56
|
|
57
|
-
# Private: The password
|
58
|
-
|
59
|
-
@password
|
60
|
-
end
|
57
|
+
# Private: The password for access to checks
|
58
|
+
mattr_accessor :password
|
61
59
|
private_class_method :password
|
62
|
-
|
63
|
-
# Private: Configure the password to access checks
|
64
|
-
def self.password=(password)
|
65
|
-
@password = password
|
66
|
-
end
|
67
60
|
private_class_method :password=
|
68
61
|
|
69
|
-
# Private:
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
# Private: Get, you know, options
|
75
|
-
def self.options
|
76
|
-
@options || {}
|
77
|
-
end
|
62
|
+
# Private: The options container
|
63
|
+
mattr_accessor :options
|
64
|
+
self.options = {}
|
78
65
|
|
79
66
|
# Private: Configure a whitelist of checks to skip authentication
|
80
67
|
def self.whitelist
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# Private: Storage of the checks which have been registered with
|
1
|
+
# Private: Storage of the checks which have been registered with OkComputer.
|
2
2
|
#
|
3
3
|
# No one is expected to interact directly with this class, but rather through
|
4
|
-
# the outer
|
5
|
-
module
|
4
|
+
# the outer OkComputer interface.
|
5
|
+
module OkComputer
|
6
6
|
class Registry
|
7
7
|
# Public: Return the check registered to the given name
|
8
8
|
#
|
@@ -22,7 +22,7 @@ module OKComputer
|
|
22
22
|
CheckCollection.new registry
|
23
23
|
end
|
24
24
|
|
25
|
-
# Public: Register the given check with
|
25
|
+
# Public: Register the given check with OkComputer
|
26
26
|
#
|
27
27
|
# check_name - The name of the check to retrieve
|
28
28
|
# check_object - Instance of Checker to register
|
data/lib/okcomputer.rb
CHANGED
@@ -1,22 +1,26 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
require "
|
1
|
+
require "ok_computer/engine"
|
2
|
+
require "ok_computer/configuration"
|
3
|
+
require "ok_computer/check"
|
4
|
+
require "ok_computer/check_collection"
|
5
|
+
require "ok_computer/registry"
|
6
6
|
|
7
7
|
# and the built-in checks
|
8
|
-
require "
|
9
|
-
require "
|
10
|
-
require "
|
11
|
-
require "
|
12
|
-
require "
|
13
|
-
require "
|
14
|
-
require "
|
15
|
-
require "
|
8
|
+
require "ok_computer/built_in_checks/size_threshold_check"
|
9
|
+
require "ok_computer/built_in_checks/active_record_check"
|
10
|
+
require "ok_computer/built_in_checks/default_check"
|
11
|
+
require "ok_computer/built_in_checks/mongoid_check"
|
12
|
+
require "ok_computer/built_in_checks/resque_backed_up_check"
|
13
|
+
require "ok_computer/built_in_checks/resque_down_check"
|
14
|
+
require "ok_computer/built_in_checks/delayed_job_backed_up_check"
|
15
|
+
require "ok_computer/built_in_checks/ruby_version_check"
|
16
|
+
require "ok_computer/built_in_checks/cache_check"
|
16
17
|
|
18
|
+
# Remove the following code in version 1.0.0
|
17
19
|
module OKComputer
|
20
|
+
def self.method_missing(*args)
|
21
|
+
raise 'Please replace all usages of `OKComputer` with `OkComputer` (lowercase `k`)'
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
|
-
|
21
|
-
|
22
|
-
|
25
|
+
OkComputer::Registry.register "default", OkComputer::DefaultCheck.new
|
26
|
+
OkComputer::Registry.register "database", OkComputer::ActiveRecordCheck.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okcomputer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Byrne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -65,29 +65,33 @@ files:
|
|
65
65
|
- MIT-LICENSE
|
66
66
|
- README.markdown
|
67
67
|
- Rakefile
|
68
|
-
- app/controllers/ok_computer_controller.rb
|
68
|
+
- app/controllers/ok_computer/ok_computer_controller.rb
|
69
69
|
- config/routes.rb
|
70
|
+
- lib/ok_computer/built_in_checks/active_record_check.rb
|
71
|
+
- lib/ok_computer/built_in_checks/cache_check.rb
|
72
|
+
- lib/ok_computer/built_in_checks/default_check.rb
|
73
|
+
- lib/ok_computer/built_in_checks/delayed_job_backed_up_check.rb
|
74
|
+
- lib/ok_computer/built_in_checks/mongoid_check.rb
|
75
|
+
- lib/ok_computer/built_in_checks/resque_backed_up_check.rb
|
76
|
+
- lib/ok_computer/built_in_checks/resque_down_check.rb
|
77
|
+
- lib/ok_computer/built_in_checks/ruby_version_check.rb
|
78
|
+
- lib/ok_computer/built_in_checks/size_threshold_check.rb
|
79
|
+
- lib/ok_computer/check.rb
|
80
|
+
- lib/ok_computer/check_collection.rb
|
81
|
+
- lib/ok_computer/configuration.rb
|
82
|
+
- lib/ok_computer/engine.rb
|
83
|
+
- lib/ok_computer/registry.rb
|
84
|
+
- lib/ok_computer/version.rb
|
70
85
|
- lib/okcomputer.rb
|
71
|
-
- lib/okcomputer/built_in_checks/active_record_check.rb
|
72
|
-
- lib/okcomputer/built_in_checks/default_check.rb
|
73
|
-
- lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb
|
74
|
-
- lib/okcomputer/built_in_checks/mongoid_check.rb
|
75
|
-
- lib/okcomputer/built_in_checks/resque_backed_up_check.rb
|
76
|
-
- lib/okcomputer/built_in_checks/resque_down_check.rb
|
77
|
-
- lib/okcomputer/built_in_checks/ruby_version_check.rb
|
78
|
-
- lib/okcomputer/built_in_checks/size_threshold_check.rb
|
79
|
-
- lib/okcomputer/check.rb
|
80
|
-
- lib/okcomputer/check_collection.rb
|
81
|
-
- lib/okcomputer/configuration.rb
|
82
|
-
- lib/okcomputer/engine.rb
|
83
|
-
- lib/okcomputer/registry.rb
|
84
|
-
- lib/okcomputer/version.rb
|
85
|
-
- lib/tasks/okcomputer_tasks.rake
|
86
86
|
homepage: https://github.com/sportngin/okcomputer
|
87
87
|
licenses:
|
88
88
|
- MIT
|
89
89
|
metadata: {}
|
90
|
-
post_install_message:
|
90
|
+
post_install_message: |
|
91
|
+
OkComputer Namespace Change (v0.7.0)
|
92
|
+
------------------------------------
|
93
|
+
OkComputer has changed its namespace from `OKComputer` (uppercase K) to `OkComputer` (lowercase k)
|
94
|
+
as of version 0.7.0. Please update your configuration accordingly.
|
91
95
|
rdoc_options: []
|
92
96
|
require_paths:
|
93
97
|
- lib
|
@@ -103,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
107
|
version: '0'
|
104
108
|
requirements: []
|
105
109
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.2.
|
110
|
+
rubygems_version: 2.2.2
|
107
111
|
signing_key:
|
108
112
|
specification_version: 4
|
109
113
|
summary: A simple, extensible health-check monitor
|
@@ -1,48 +0,0 @@
|
|
1
|
-
class OkComputerController < ActionController::Base
|
2
|
-
layout nil
|
3
|
-
respond_to :text, :html, :json
|
4
|
-
|
5
|
-
before_filter :authenticate
|
6
|
-
|
7
|
-
rescue_from OKComputer::Registry::CheckNotFound do |e|
|
8
|
-
respond_to do |f|
|
9
|
-
f.any(:text, :html) { render text: e.message, status: :not_found }
|
10
|
-
f.json { render json: { error: e.message }, status: :not_found }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def index
|
15
|
-
checks = OKComputer::Registry.all
|
16
|
-
checks.run
|
17
|
-
|
18
|
-
respond checks, status_code(checks)
|
19
|
-
end
|
20
|
-
|
21
|
-
def show
|
22
|
-
check = OKComputer::Registry.fetch(params[:check])
|
23
|
-
check.run
|
24
|
-
|
25
|
-
respond check, status_code(check)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def respond(data, status)
|
31
|
-
respond_to do |format|
|
32
|
-
format.any(:text, :html) { render text: data, status: status }
|
33
|
-
format.json { render json: data, status: status }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def status_code(check)
|
38
|
-
check.success? ? :ok : :error
|
39
|
-
end
|
40
|
-
|
41
|
-
def authenticate
|
42
|
-
if OKComputer.requires_authentication?(params)
|
43
|
-
authenticate_or_request_with_http_basic do |username, password|
|
44
|
-
OKComputer.authenticate(username, password)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
data/lib/okcomputer/engine.rb
DELETED
data/lib/okcomputer/version.rb
DELETED