okcomputer 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[![Code Climate](https://codeclimate.com/github/
|
2
|
-
[![Build Status](https://travis-ci.org/
|
1
|
+
[![Code Climate](https://codeclimate.com/github/sportngin/okcomputer.png)](https://codeclimate.com/github/sportngin/okcomputer)
|
2
|
+
[![Build Status](https://travis-ci.org/sportngin/okcomputer.png)](https://travis-ci.org/sportngin/okcomputer)
|
3
3
|
|
4
4
|
# OK Computer
|
5
5
|
|
data/lib/okcomputer.rb
CHANGED
@@ -10,6 +10,7 @@ require "okcomputer/built_in_checks/default_check"
|
|
10
10
|
require "okcomputer/built_in_checks/mongoid_check"
|
11
11
|
require "okcomputer/built_in_checks/resque_backed_up_check"
|
12
12
|
require "okcomputer/built_in_checks/resque_down_check"
|
13
|
+
require "okcomputer/built_in_checks/delayed_job_backed_up_check"
|
13
14
|
|
14
15
|
module OKComputer
|
15
16
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module OKComputer
|
2
|
+
class DelayedJobBackedUpCheck < Check
|
3
|
+
attr_accessor :priority
|
4
|
+
attr_accessor :threshold
|
5
|
+
|
6
|
+
# Public: Initialize a check for backed-up Delayed Job jobs
|
7
|
+
#
|
8
|
+
# priority - Which priority (or greater) to check for
|
9
|
+
# threshold - An Integer to compare the jobs count against
|
10
|
+
# to consider it backed up
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
# check = new(10, 50)
|
14
|
+
# # => The check will look for jobs with priority between
|
15
|
+
# # 0 and 10, considering the jobs as backed up if there
|
16
|
+
# # are more than 50 of them
|
17
|
+
def initialize(priority, threshold)
|
18
|
+
self.priority = Integer(priority)
|
19
|
+
self.threshold = Integer(threshold)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Public: Check and report whether delayed jobs are backed up
|
23
|
+
def check
|
24
|
+
if backed_up?
|
25
|
+
mark_failure
|
26
|
+
mark_message "Delayed Jobs within priority '#{priority}' backed up! (#{count})"
|
27
|
+
else
|
28
|
+
mark_message "Delayed Jobs within priority '#{priority}' at reasonable level (#{count})"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Public: Whether delayed jobs are backed up
|
33
|
+
#
|
34
|
+
# Returns a Boolean
|
35
|
+
def backed_up?
|
36
|
+
count > threshold
|
37
|
+
end
|
38
|
+
|
39
|
+
# Public: How many delayed jobs are pending within the given priority
|
40
|
+
def count
|
41
|
+
Delayed::Job.where("priority <= ?", priority).where(:locked_at => nil, :last_error => nil).count
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/okcomputer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okcomputer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- config/routes.rb
|
74
74
|
- lib/okcomputer/built_in_checks/active_record_check.rb
|
75
75
|
- lib/okcomputer/built_in_checks/default_check.rb
|
76
|
+
- lib/okcomputer/built_in_checks/delayed_job_backed_up_check.rb
|
76
77
|
- lib/okcomputer/built_in_checks/mongoid_check.rb
|
77
78
|
- lib/okcomputer/built_in_checks/resque_backed_up_check.rb
|
78
79
|
- lib/okcomputer/built_in_checks/resque_down_check.rb
|
@@ -99,15 +100,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
100
|
- - ! '>='
|
100
101
|
- !ruby/object:Gem::Version
|
101
102
|
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: -1102877545554144384
|
102
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
107
|
none: false
|
104
108
|
requirements:
|
105
109
|
- - ! '>='
|
106
110
|
- !ruby/object:Gem::Version
|
107
111
|
version: '0'
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
hash: -1102877545554144384
|
108
115
|
requirements: []
|
109
116
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.23
|
111
118
|
signing_key:
|
112
119
|
specification_version: 3
|
113
120
|
summary: A simple, extensible health-check monitor
|