sensu-plugins-resque 0.0.4 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 134d676954779ffe84c704dea50c2f552e8cef79
4
- data.tar.gz: 264254feaef7944e833799bb0c25c2506317546a
3
+ metadata.gz: fdab75b2262f44050c3e5bf0ef9ee508aad47813
4
+ data.tar.gz: ee90c442a710a772fb21cecd2580cb5e893305d3
5
5
  SHA512:
6
- metadata.gz: 33a9aa5c6db4b3465119cd83a15e1e6ae8e01859a7c71ae7eaefa5bb5ed5d2077e5a60538edfa4dc209dc346492e1f4c7055c1404928cb908322e7568e034865
7
- data.tar.gz: e14f18e13e4989b68542ad30b257570544f91dafd741132bbdb7352a718394210802b71f82ce52966fdb8e480f3b12b5b8750705ae851e41afacb9da9b3680b7
6
+ metadata.gz: 081ff30c0a1718325c6fcdc1d06b0d0d5644b5ea7a3c86fa02f9d9303d977a0fc8f21f3b1a988e08faaef97aa10544fa170fa11844af2c544b7b8eefb509edbf
7
+ data.tar.gz: fc8c4b183bd8c20e08dca0041042d0a6a0cd0688464fa9e88ab2a2f0407ade636306e9175b726d3a2ebaf44fdd3963db3a3399b41d537cd9a8b8d34d5d49ea7d
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -3,7 +3,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
- ## Unreleased][unreleased]
6
+ ## Unreleased
7
+
8
+ ## [0.1.0] - 2015-11-19
9
+ ### Added
10
+ - check timeouts: new script to raise an alert when a job has been running for too much time
11
+
12
+ ### Changed
13
+ - Update to rubocop 0.32.1
14
+ - metrics-resque.rb: format queue name to be graphite friendly
7
15
 
8
16
  ## [0.0.4] - 2015-07-14
9
17
  ### Changed
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Sensu-Plugins-resque
2
2
 
3
- [ ![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-resque.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-resque)
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-resque.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-resque)
4
4
  [![Gem Version](https://badge.fury.io/rb/sensu-plugins-resque.svg)](http://badge.fury.io/rb/sensu-plugins-resque)
5
5
  [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-resque/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-resque)
6
6
  [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-resque/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-resque)
@@ -11,6 +11,7 @@
11
11
 
12
12
  ## Files
13
13
  * bin/metrics-resque.rb
14
+ * bin/check-timeouts-resque.rb
14
15
 
15
16
  ## Usage
16
17
 
@@ -0,0 +1,109 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # resque-timeouts
4
+ #
5
+ # DESCRIPTION:
6
+ # Monitor Resque queues for jobs that are taking too long
7
+ #
8
+ # OUTPUT:
9
+ # List of jobs that are taking too long
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: socket
17
+ # gem: resque
18
+ #
19
+ # USAGE:
20
+ # #YELLOW
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Copyright 2015 Mark Wallsgrove <mw@talis.com>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/check/cli'
31
+ require 'socket'
32
+ require 'resque'
33
+ require 'resque/failure/redis'
34
+ require 'date'
35
+
36
+ class ResqueTimeouts < Sensu::Plugin::Check::CLI
37
+ option :hostname,
38
+ short: '-h HOSTNAME',
39
+ long: '--host HOSTNAME',
40
+ description: 'Redis hostname',
41
+ required: true
42
+
43
+ option :port,
44
+ short: '-P PORT',
45
+ long: '--port PORT',
46
+ description: 'Redis port',
47
+ default: '6379'
48
+
49
+ option :db,
50
+ short: '-d DB',
51
+ long: '--db DB',
52
+ description: 'Redis DB',
53
+ default: '0'
54
+
55
+ option :namespace,
56
+ description: 'Resque namespace',
57
+ short: '-n NAMESPACE',
58
+ long: '--namespace NAMESPACE',
59
+ default: 'resque'
60
+
61
+ option :queue,
62
+ description: 'Name of queue to check',
63
+ short: '-q QUEUE',
64
+ long: '--queue QUEUE',
65
+ required: true
66
+
67
+ option :max_lifetime,
68
+ description: 'Maximum amount of time a job should consume',
69
+ short: '-t TIME_SECS',
70
+ long: '--time TIME_SECS',
71
+ required: true
72
+
73
+ def run
74
+ redis = Redis.new(
75
+ host: config[:hostname],
76
+ port: config[:port],
77
+ db: config[:db]
78
+ )
79
+
80
+ Resque.redis = redis
81
+ Resque.redis.namespace = config[:namespace]
82
+
83
+ max_lifetime = config[:max_lifetime].to_i > 0 ? config[:max_lifetime].to_i : 100
84
+ queue_name = config[:queue]
85
+
86
+ workers = Resque.working
87
+ jobs = workers.collect(&:job)
88
+ worker_jobs = workers.zip(jobs)
89
+
90
+ job_timeout = false
91
+
92
+ worker_jobs.each do |worker, job|
93
+ next unless queue_name == job['queue']
94
+ host, pid = worker.to_s.split(':')
95
+ diff_secs = (Time.now - Time.parse(job['run_at'])).round
96
+
97
+ next if diff_secs <= max_lifetime
98
+ output "#{host} (pid: #{pid}) is taking too much time at #{diff_secs} "\
99
+ "seconds (max: #{max_lifetime}) on class #{job['payload']['class']}"
100
+ job_timeout = true
101
+ end
102
+
103
+ if job_timeout
104
+ critical
105
+ else
106
+ ok
107
+ end
108
+ end
109
+ end
@@ -70,9 +70,10 @@ class ResqueMetrics < Sensu::Plugin::Metric::CLI::Graphite
70
70
  count = Resque::Failure::Redis.count
71
71
  info = Resque.info
72
72
 
73
- Resque.queues.each do |v|
74
- sz = Resque.size(v)
75
- output "#{config[:scheme]}.queue.#{v}", sz
73
+ Resque.queues.each do |q|
74
+ sz = Resque.size(q)
75
+ qn = q.gsub(/[^\w-]/, '_').downcase
76
+ output "#{config[:scheme]}.queue.#{qn}", sz
76
77
  end
77
78
 
78
79
  output "#{config[:scheme]}.queues", info[:queues]
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsResque
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- PATCH = 4
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-resque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-07-14 00:00:00.000000000 Z
33
+ date: 2015-11-19 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: resque
@@ -164,14 +164,14 @@ dependencies:
164
164
  requirements:
165
165
  - - '='
166
166
  - !ruby/object:Gem::Version
167
- version: '0.30'
167
+ version: 0.32.1
168
168
  type: :development
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - '='
173
173
  - !ruby/object:Gem::Version
174
- version: '0.30'
174
+ version: 0.32.1
175
175
  - !ruby/object:Gem::Dependency
176
176
  name: yard
177
177
  requirement: !ruby/object:Gem::Requirement
@@ -190,12 +190,14 @@ description: Sensu plugins for resque
190
190
  email: "<sensu-users@googlegroups.com>"
191
191
  executables:
192
192
  - metrics-resque.rb
193
+ - check-timeouts-resque.rb
193
194
  extensions: []
194
195
  extra_rdoc_files: []
195
196
  files:
196
197
  - CHANGELOG.md
197
198
  - LICENSE
198
199
  - README.md
200
+ - bin/check-timeouts-resque.rb
199
201
  - bin/metrics-resque.rb
200
202
  - lib/sensu-plugins-resque.rb
201
203
  - lib/sensu-plugins-resque/version.rb
@@ -225,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
227
  version: '0'
226
228
  requirements: []
227
229
  rubyforge_project:
228
- rubygems_version: 2.4.6
230
+ rubygems_version: 2.4.8
229
231
  signing_key:
230
232
  specification_version: 4
231
233
  summary: Sensu plugins for resque
metadata.gz.sig CHANGED
Binary file