nagios_check_resque 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +11 -1
- data/Gemfile +2 -0
- data/README.md +16 -4
- data/Rakefile +4 -0
- data/bin/rake +17 -0
- data/bin/rspec +17 -0
- data/lib/nagios_check_resque.rb +0 -1
- data/lib/nagios_check_resque/failed_jobs_check.rb +10 -11
- data/lib/nagios_check_resque/queue_size_check.rb +15 -8
- data/lib/nagios_check_resque/resque_adapter.rb +18 -0
- data/lib/nagios_check_resque/version.rb +1 -1
- data/nagios_check_resque.gemspec +3 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c7350790cc753e49727fed05140218542a07708
|
4
|
+
data.tar.gz: 69ef4dae4f26fd19e33f5154a26b57683faf944f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68bf5833da6dd7b1c98ebab42b87b0d87a1c97145bd2470896753d752e28895e013902f59ca18cce47d191069859c403dfb83d4b179bd1997bdee952bc12bbce
|
7
|
+
data.tar.gz: b90a817a4b9a544f32bceb6e1d7eff74c54bdf9ff59c1466dddf226212b1f127e2c3ce046f1412bc9aab8c6a3ef99d5f3113a3c09685404398a2a29bfadd3dd2
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -2,10 +2,20 @@
|
|
2
2
|
|
3
3
|
### Changes on `master`
|
4
4
|
|
5
|
-
[Compare changes](https://github.com/codevise/nagios_check_resque/compare/v1.
|
5
|
+
[Compare changes](https://github.com/codevise/nagios_check_resque/compare/v1.1.0...master)
|
6
6
|
|
7
7
|
None so far.
|
8
8
|
|
9
|
+
### Version 1.1.0
|
10
|
+
|
11
|
+
2017-05-26
|
12
|
+
|
13
|
+
[Compare changes](https://github.com/codevise/nagios_check_resque/compare/v1.0.0...v1.1.0)
|
14
|
+
|
15
|
+
- Allow passing custom Redis URL as environment variable or command
|
16
|
+
line option.
|
17
|
+
- Make checks store human readable message.
|
18
|
+
|
9
19
|
### Version 1.0.0
|
10
20
|
|
11
21
|
2017-02-21
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# Nagios Check Resque
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/nagios_check_resque.svg)](http://badge.fury.io/rb/nagios_check_resque)
|
4
|
+
[![Build Status](https://travis-ci.org/codevise/nagios_check_resque.svg?branch=master)](https://travis-ci.org/codevise/nagios_check_resque)
|
4
5
|
|
5
|
-
Nagios plugins to check Resque queue
|
6
|
+
Nagios plugins to check Resque queue sizes and number of failed jobs.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
10
|
Add this line to your application's Gemfile:
|
10
11
|
|
11
12
|
```ruby
|
12
|
-
gem 'nagios_check_resque', require: false
|
13
|
+
gem 'nagios_check_resque', '~> 1.0', require: false
|
13
14
|
```
|
14
15
|
|
15
16
|
And then execute:
|
@@ -40,6 +41,16 @@ more than 5 failed jobs but not more than 8, the result is WARNING.
|
|
40
41
|
If there are more than 8 failed jobs, the result is CRITICAL. If the
|
41
42
|
command takes more than 10 seconds to finish, the result is UNKNOWN.
|
42
43
|
|
44
|
+
## Specifying a Redis URL
|
45
|
+
|
46
|
+
By default the checks assume that Redis is accessible at
|
47
|
+
`localhost:6379`. A different Redis URL can either be passed via the
|
48
|
+
command line:
|
49
|
+
|
50
|
+
$ bundle exec nagios_check_resque_failed_jobs -w 5 -c 8 -t 10 --redis-url redis://other:6379
|
51
|
+
|
52
|
+
or by setting the environment variable `REDIS_URL`.
|
53
|
+
|
43
54
|
## Example Nagios Configuration
|
44
55
|
|
45
56
|
You can define a custom Nagios command to invoke the executables via
|
@@ -86,8 +97,9 @@ define service {
|
|
86
97
|
## Development
|
87
98
|
|
88
99
|
After checking out the repo, run `bin/setup` to install
|
89
|
-
dependencies.
|
90
|
-
that will allow you to
|
100
|
+
dependencies. Run `bin/rspec` to execute the test suite. You can also
|
101
|
+
run `bin/console` for an interactive prompt that will allow you to
|
102
|
+
experiment.
|
91
103
|
|
92
104
|
To install this gem onto your local machine, run `bundle exec rake
|
93
105
|
install`. To release a new version, update the version number in
|
data/Rakefile
CHANGED
data/bin/rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rake' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rspec' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/lib/nagios_check_resque.rb
CHANGED
@@ -1,29 +1,28 @@
|
|
1
1
|
require 'nagios_check'
|
2
|
-
|
3
|
-
require 'resque'
|
4
|
-
require 'resque/failure/redis'
|
2
|
+
require 'nagios_check_resque/resque_adapter'
|
5
3
|
|
6
4
|
module NagiosCheckResque
|
7
5
|
# Warn if there are failed jobs
|
8
6
|
class FailedJobsCheck
|
9
7
|
include NagiosCheck
|
10
8
|
|
11
|
-
on '--redis-
|
9
|
+
on '--redis-url URL', default: ENV.fetch('REDIS_URL', 'redis://localhost:6379')
|
12
10
|
|
13
11
|
enable_warning
|
14
12
|
enable_critical
|
15
13
|
enable_timeout
|
16
14
|
|
17
|
-
def
|
18
|
-
|
19
|
-
store_value(:failed, Resque::Failure::Redis.count)
|
15
|
+
def initialize(resque = ResqueAdapter.new)
|
16
|
+
@resque = resque
|
20
17
|
end
|
21
18
|
|
22
|
-
|
19
|
+
def check
|
20
|
+
@resque.setup(redis_url: options['redis-url'])
|
21
|
+
|
22
|
+
failed_jobs_count = @resque.failed_count
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
Resque
|
24
|
+
store_message("#{failed_jobs_count} failed jobs")
|
25
|
+
store_value(:failed, failed_jobs_count)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'nagios_check'
|
2
|
-
require '
|
2
|
+
require 'nagios_check_resque/resque_adapter'
|
3
3
|
|
4
4
|
module NagiosCheckResque
|
5
5
|
# Prevent jobs from queuing up
|
@@ -7,15 +7,20 @@ module NagiosCheckResque
|
|
7
7
|
include NagiosCheck
|
8
8
|
|
9
9
|
on '--queues QUEUES', :mandatory
|
10
|
-
on '--redis-
|
10
|
+
on '--redis-url URL', default: ENV.fetch('REDIS_URL', 'redis://localhost:6379')
|
11
11
|
|
12
12
|
enable_warning
|
13
13
|
enable_critical
|
14
14
|
enable_timeout
|
15
15
|
|
16
|
+
def initialize(resque = ResqueAdapter.new)
|
17
|
+
@resque = resque
|
18
|
+
end
|
19
|
+
|
16
20
|
def check
|
17
|
-
|
21
|
+
@resque.setup(redis_url: options['redis-url'])
|
18
22
|
|
23
|
+
store_message(queue_sizes_message)
|
19
24
|
store_value(:max, queue_sizes.values.max)
|
20
25
|
|
21
26
|
queue_sizes.each do |name, size|
|
@@ -25,18 +30,20 @@ module NagiosCheckResque
|
|
25
30
|
|
26
31
|
private
|
27
32
|
|
33
|
+
def queue_sizes_message
|
34
|
+
queue_sizes.sort_by { |_, size| size }.reverse.map { |name, size|
|
35
|
+
"#{size} in #{name}"
|
36
|
+
}.compact.join(', ')
|
37
|
+
end
|
38
|
+
|
28
39
|
def queue_sizes
|
29
40
|
@queue_sizes ||= queues.each_with_object({}) do |name, sizes|
|
30
|
-
sizes[name] =
|
41
|
+
sizes[name] = @resque.queue_size(name)
|
31
42
|
end
|
32
43
|
end
|
33
44
|
|
34
45
|
def queues
|
35
46
|
options.queues.split(',')
|
36
47
|
end
|
37
|
-
|
38
|
-
def setup_resque
|
39
|
-
Resque.redis = Redis.new(host: options.redis_host)
|
40
|
-
end
|
41
48
|
end
|
42
49
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'resque'
|
2
|
+
require 'resque/failure/redis'
|
3
|
+
|
4
|
+
module NagiosCheckResque
|
5
|
+
class ResqueAdapter
|
6
|
+
def setup(options)
|
7
|
+
Resque.redis = options[:redis_url]
|
8
|
+
end
|
9
|
+
|
10
|
+
def queue_size(queue)
|
11
|
+
Resque.size(queue)
|
12
|
+
end
|
13
|
+
|
14
|
+
def failed_count
|
15
|
+
Resque::Failure::Redis.count
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/nagios_check_resque.gemspec
CHANGED
@@ -20,9 +20,12 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
+
spec.required_ruby_version = '>= 2.0'
|
24
|
+
|
23
25
|
spec.add_dependency 'nagios_check', '~> 0.4.0'
|
24
26
|
spec.add_dependency 'resque', '~> 1.25'
|
25
27
|
|
26
28
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
29
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.6'
|
28
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nagios_check_resque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codevise Solutions Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nagios_check
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.6'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- info@codevise.de
|
@@ -76,6 +90,8 @@ extensions: []
|
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
92
|
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".travis.yml"
|
79
95
|
- CHANGELOG.md
|
80
96
|
- CODE_OF_CONDUCT.md
|
81
97
|
- Gemfile
|
@@ -83,12 +99,15 @@ files:
|
|
83
99
|
- README.md
|
84
100
|
- Rakefile
|
85
101
|
- bin/console
|
102
|
+
- bin/rake
|
103
|
+
- bin/rspec
|
86
104
|
- bin/setup
|
87
105
|
- exe/nagios_check_resque_failed_jobs
|
88
106
|
- exe/nagios_check_resque_queue_sizes
|
89
107
|
- lib/nagios_check_resque.rb
|
90
108
|
- lib/nagios_check_resque/failed_jobs_check.rb
|
91
109
|
- lib/nagios_check_resque/queue_size_check.rb
|
110
|
+
- lib/nagios_check_resque/resque_adapter.rb
|
92
111
|
- lib/nagios_check_resque/version.rb
|
93
112
|
- nagios_check_resque.gemspec
|
94
113
|
homepage: http://github.com/codevise/nagios_check_resque
|
@@ -103,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
122
|
requirements:
|
104
123
|
- - ">="
|
105
124
|
- !ruby/object:Gem::Version
|
106
|
-
version: '0'
|
125
|
+
version: '2.0'
|
107
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
127
|
requirements:
|
109
128
|
- - ">="
|