sensu-plugins-sidekiq-latency 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +31 -0
- data/Rakefile +6 -0
- data/bin/check-sidekiq-latency.rb +79 -0
- data/lib/latency.rb +1 -0
- data/lib/sensu-plugin-sidekiq-latency/version.rb +3 -0
- data/sensu-plugins-sidekiq-latency.gemspec +27 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c97151db3884ed62711b8cc25926f18c8c7c4361
|
4
|
+
data.tar.gz: 96a95c4d0e436860355ca2f2228f7cfbaeebbf14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 97dee28288e91bff47d1f2b55086280d8cdb065e3d82288b02cc29807292bd9db5edaa3ba684141384b75c580dd5c39e5e437dccdcda75cf6901a4211457f9ab
|
7
|
+
data.tar.gz: 2fae930576d68f937cda30db4e846019d584a461bf02c6e2ab2cbcb60f255f145d147990280df7184067d1a787b96d72e5ad450861db6abe05e8961f72d3c611
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# sensu-plugins-sidekiq-latency
|
2
|
+
|
3
|
+
This is a Sensu plugin that allows monitoring and alerting if the latency of
|
4
|
+
a Sidekiq queue exceeds a threshold value. It talks directly to Redis, so that
|
5
|
+
it doesn't need to authenticate to the Sidekiq web interface.
|
6
|
+
|
7
|
+
# Installation
|
8
|
+
|
9
|
+
Or install it yourself as:
|
10
|
+
|
11
|
+
$ gem install sensu-plugins-sidekiq-latency
|
12
|
+
|
13
|
+
# Functionality
|
14
|
+
|
15
|
+
## check-sidekiq-latency.rb
|
16
|
+
Checks the latency for a particular sidekiq queue, and warns if it exceeds thresholds.
|
17
|
+
|
18
|
+
- `--url` or `-u` - **required** URL of the Redis instance that Sidekiq is using.
|
19
|
+
- `--queue` or `-q` - **required** name of the sidekiq queue to monitor.
|
20
|
+
- `--warn` or `-w` - threshold (in seconds) for a warning to be issued.
|
21
|
+
- `--crit` or `-c` - threshold (in seconds) for a critical alert to be sent.
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/chartmogul/sensu-plugin-sidekiq-latency. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
data/Rakefile
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require 'sensu-plugin/check/cli'
|
5
|
+
require 'sidekiq/api'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
# check-sidekiq-latency
|
10
|
+
#
|
11
|
+
# DESCRIPTION:
|
12
|
+
# Checks a particular sidekiq queue for maximum latency
|
13
|
+
#
|
14
|
+
# https://github.com/chartmogul/sensu-plugin-sidekiq-latency
|
15
|
+
#
|
16
|
+
# Returns warning/critical if latency exceeds certain thresholds
|
17
|
+
#
|
18
|
+
# PLATFORMS:
|
19
|
+
# Linux
|
20
|
+
#
|
21
|
+
# DEPENDENCIES:
|
22
|
+
# gem: sidekiq
|
23
|
+
# gem: sensu-plugin
|
24
|
+
# gem: open-uri
|
25
|
+
# gem: json
|
26
|
+
#
|
27
|
+
# LICENSE:
|
28
|
+
# Jason Langenauer <jason@chartmogul.com>
|
29
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
30
|
+
# for details.
|
31
|
+
#
|
32
|
+
class SidekiqLatencyCheck < Sensu::Plugin::Check::CLI
|
33
|
+
option :redis_url,
|
34
|
+
short: '-u URL',
|
35
|
+
long: '--url URL',
|
36
|
+
description: 'Redis URL to query',
|
37
|
+
required: true
|
38
|
+
|
39
|
+
option :queue,
|
40
|
+
short: '-q QUEUE',
|
41
|
+
long: '--queue QUEUE',
|
42
|
+
description: 'Queue with latency to check',
|
43
|
+
required: true
|
44
|
+
|
45
|
+
option :warn,
|
46
|
+
short: '-w SECONDS',
|
47
|
+
long: '--warn SECONDS',
|
48
|
+
description: 'Warn after any job has been SECONDS seconds in the queue',
|
49
|
+
proc: proc { |seconds| seconds.to_i },
|
50
|
+
default: 120
|
51
|
+
|
52
|
+
option :crit,
|
53
|
+
short: '-c SECONDS',
|
54
|
+
long: '--crit SECONDS',
|
55
|
+
description: 'Critical after any job has been SECONDS seconds in the queue',
|
56
|
+
proc: proc { |seconds| seconds.to_i },
|
57
|
+
default: 300
|
58
|
+
|
59
|
+
def run
|
60
|
+
begin
|
61
|
+
Sidekiq.configure_client do |sidekiq_config|
|
62
|
+
sidekiq_config.redis = { url: config[:url] }
|
63
|
+
end
|
64
|
+
|
65
|
+
latency = Sidekiq::Queue.new(config[:queue]).latency.to_i
|
66
|
+
|
67
|
+
if latency > config[:warn]
|
68
|
+
warning "The latency of Sidekiq queue '#{config[:queue]}' is more than #{config[:warn]} seconds"
|
69
|
+
elsif latency > config[:crit]
|
70
|
+
critical "The latency of Sidekiq queue '#{config[:queue]}' is more than #{config[:crit]} seconds"
|
71
|
+
end
|
72
|
+
|
73
|
+
ok "Maximum latency for Sidekiq queue '#{config[:queue]}' is less than #{config[:warn]} seconds"
|
74
|
+
|
75
|
+
rescue => error
|
76
|
+
unknown "Could not load Sidekiq stats from #{config[:url]}. Error: #{error}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/latency.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "sensu-plugin-sidekiq-latency/version"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sensu-plugin-sidekiq-latency/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'sensu-plugins-sidekiq-latency'
|
8
|
+
spec.version = SensuPluginSidekiqLatency::VERSION
|
9
|
+
spec.authors = ['Jason Langenauer']
|
10
|
+
spec.email = ['jason@chartmogul.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Sensu Plugin to alert on Sidekiq latency of a particular queue}
|
13
|
+
spec.description = %q{Sensu Plugin to alert on Sidekiq latency of a particular queue}
|
14
|
+
spec.homepage = 'https://github.com/chartmogul/sensu-plugin-sidekiq-latency'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'sensu-plugin', '~> 1.2'
|
22
|
+
spec.add_dependency 'sidekiq', '>= 3.5'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-sidekiq-latency
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Langenauer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-plugin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sidekiq
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
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: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Sensu Plugin to alert on Sidekiq latency of a particular queue
|
84
|
+
email:
|
85
|
+
- jason@chartmogul.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/check-sidekiq-latency.rb
|
97
|
+
- lib/latency.rb
|
98
|
+
- lib/sensu-plugin-sidekiq-latency/version.rb
|
99
|
+
- sensu-plugins-sidekiq-latency.gemspec
|
100
|
+
homepage: https://github.com/chartmogul/sensu-plugin-sidekiq-latency
|
101
|
+
licenses: []
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.5.1
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Sensu Plugin to alert on Sidekiq latency of a particular queue
|
123
|
+
test_files: []
|
124
|
+
has_rdoc:
|