sensu-plugins-beanstalk 0.0.1.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE +22 -0
- data/README.md +58 -0
- data/bin/check-beanstalk-jobs.rb +93 -0
- data/bin/check-beanstalk-statistic.rb +97 -0
- data/bin/check-beanstalk-watchers-to-buried.rb +83 -0
- data/bin/check-beanstalk-watchers.rb +81 -0
- data/bin/check-beanstalkd.rb +129 -0
- data/bin/metrics-beanstalkd.rb +75 -0
- data/lib/sensu-plugins-beanstalk.rb +7 -0
- data.tar.gz.sig +0 -0
- metadata +261 -0
- metadata.gz.sig +2 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83ede6b016cadaa1959b3ad49c42895c29264223
|
4
|
+
data.tar.gz: 352ea80732da69931b7d3f1abaf3f10ca2017c0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 13a6bd3cc5823588f5487e20c99637897b69c018f312726f9a5f3027333189f71dd92164f59e731730249ef5528ba49c527fcc5b848d646416ce7f75d006ae7d
|
7
|
+
data.tar.gz: e7f56ad8002db32a23a6281268b80f2beabe33a0ffef3cb6b4808fc12c6912c6d0c07773ec88dcf39c093aed396a90486d32f70f01befc20bfbbcef553d58b95
|
checksums.yaml.gz.sig
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 devops@yieldbot.com
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
## Sensu-Plugins-beanstalk
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-beanstalk.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-beanstalk)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-beanstalk.svg)](http://badge.fury.io/rb/sensu-plugins-beanstalk)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-beanstalk/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-beanstalk)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-beanstalk/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-beanstalk)
|
7
|
+
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-beanstalk.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-beanstalk)
|
8
|
+
|
9
|
+
## Functionality
|
10
|
+
|
11
|
+
## Files
|
12
|
+
|
13
|
+
* bin/metrics-beanstalkd
|
14
|
+
* bin/check-beanstalk-jobs
|
15
|
+
* bin/check-beanstalk-watchers
|
16
|
+
* bin/check-beanstalk-watchers-to-buried
|
17
|
+
* bin/check-beanstalkd
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add the public key (if you haven’t already) as a trusted certificate
|
24
|
+
|
25
|
+
```
|
26
|
+
gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem)
|
27
|
+
gem install sensu-plugins-beanstalk -P MediumSecurity
|
28
|
+
```
|
29
|
+
|
30
|
+
You can also download the key from /certs/ within each repository.
|
31
|
+
|
32
|
+
#### Rubygems
|
33
|
+
|
34
|
+
`gem install sensu-plugins-beanstalk`
|
35
|
+
|
36
|
+
#### Bundler
|
37
|
+
|
38
|
+
Add *sensu-plugins-beanstalk* to your Gemfile and run `bundle install` or `bundle update`
|
39
|
+
|
40
|
+
#### Chef
|
41
|
+
|
42
|
+
Using the Sensu **sensu_gem** LWRP
|
43
|
+
```
|
44
|
+
sensu_gem 'sensu-plugins-beanstalk' do
|
45
|
+
options('--prerelease')
|
46
|
+
version '0.0.1'
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
Using the Chef **gem_package** resource
|
51
|
+
```
|
52
|
+
gem_package 'sensu-plugins-beanstalk' do
|
53
|
+
options('--prerelease')
|
54
|
+
version '0.0.1'
|
55
|
+
end
|
56
|
+
```
|
57
|
+
|
58
|
+
## Notes
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-beanstalk-jobs
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# #YELLOW
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: beanstalk
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# #YELLOW
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright S. Zachariah Sprackett <zac@sprackett.com>
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
require 'beanstalk-client'
|
31
|
+
|
32
|
+
#
|
33
|
+
# Check Beanstalk Workers
|
34
|
+
#
|
35
|
+
class CheckBeanstalkWorkers < Sensu::Plugin::Check::CLI
|
36
|
+
option :host,
|
37
|
+
short: '-H HOST',
|
38
|
+
default: 'localhost'
|
39
|
+
option :port,
|
40
|
+
short: '-p PORT',
|
41
|
+
default: '11300'
|
42
|
+
option :tube,
|
43
|
+
short: '-t TUBE'
|
44
|
+
option :crit_high,
|
45
|
+
short: '-c CRIT_HIGH_THRESHOLD',
|
46
|
+
proc: proc(&:to_i),
|
47
|
+
default: false
|
48
|
+
option :warn_high,
|
49
|
+
short: '-w WARN_HIGH_THRESHOLD',
|
50
|
+
proc: proc(&:to_i),
|
51
|
+
default: false
|
52
|
+
option :crit_low,
|
53
|
+
short: '-C CRIT_LOW_THRESHOLD',
|
54
|
+
proc: proc(&:to_i),
|
55
|
+
default: 0
|
56
|
+
option :warn_low,
|
57
|
+
short: '-W WARN_LOW_THRESHOLD',
|
58
|
+
proc: proc(&:to_i),
|
59
|
+
default: 0
|
60
|
+
|
61
|
+
def run # rubocop:disable all
|
62
|
+
begin
|
63
|
+
beanstalk = Beanstalk::Connection.new(
|
64
|
+
"#{config[:host]}:#{config[:port]}"
|
65
|
+
)
|
66
|
+
rescue => e
|
67
|
+
critical "Failed to connect: (#{e})"
|
68
|
+
end
|
69
|
+
|
70
|
+
if config[:tube]
|
71
|
+
begin
|
72
|
+
stats = beanstalk.stats_tube(config[:tube])
|
73
|
+
rescue Beanstalk::NotFoundError
|
74
|
+
warning "Tube #{config[:tube]} not found"
|
75
|
+
end
|
76
|
+
else
|
77
|
+
stats = beanstalk.stats
|
78
|
+
end
|
79
|
+
jobs = stats['current-jobs-ready'] + stats['current-jobs-delayed']
|
80
|
+
|
81
|
+
if config[:crit_high] && jobs > config[:crit_high]
|
82
|
+
critical "High threshold is #{config[:crit_high]} jobs (#{jobs} active jobs)"
|
83
|
+
elsif config[:warn_high] && jobs > config[:warn_high]
|
84
|
+
warning "High threshold is #{config[:warn_high]} jobs (#{jobs} active jobs)"
|
85
|
+
elsif jobs < config[:crit_low]
|
86
|
+
warning "Low threshold is #{config[:crit_low]} jobs (#{jobs} active jobs)"
|
87
|
+
elsif jobs < config[:warn_low]
|
88
|
+
warning "Low threshold is #{config[:warn_low]} (#{jobs} active jobs)"
|
89
|
+
else
|
90
|
+
ok "#{jobs} jobs found."
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-beanstalk-statistic
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# #YELLOW
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: beanstalk
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# #YELLOW
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright S. Zachariah Sprackett <zac@sprackett.com>
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
require 'beanstalk-client'
|
31
|
+
|
32
|
+
#
|
33
|
+
# Check beanstalk Statistics
|
34
|
+
#
|
35
|
+
class CheckBeanstalkStatistic < Sensu::Plugin::Check::CLI
|
36
|
+
option :host,
|
37
|
+
short: '-H HOST',
|
38
|
+
default: 'localhost'
|
39
|
+
option :port,
|
40
|
+
short: '-p PORT',
|
41
|
+
default: '11300'
|
42
|
+
option :tube,
|
43
|
+
short: '-t TUBE'
|
44
|
+
option :stat,
|
45
|
+
short: '-s STAT'
|
46
|
+
option :crit_high,
|
47
|
+
short: '-c CRIT_HIGH_THRESHOLD',
|
48
|
+
proc: proc(&:to_i),
|
49
|
+
default: false
|
50
|
+
option :warn_high,
|
51
|
+
short: '-w WARN_HIGH_THRESHOLD',
|
52
|
+
proc: proc(&:to_i),
|
53
|
+
default: false
|
54
|
+
option :crit_low,
|
55
|
+
short: '-C CRIT_LOW_THRESHOLD',
|
56
|
+
proc: proc(&:to_i),
|
57
|
+
default: 0
|
58
|
+
option :warn_low,
|
59
|
+
short: '-W WARN_LOW_THRESHOLD',
|
60
|
+
proc: proc(&:to_i),
|
61
|
+
default: 0
|
62
|
+
|
63
|
+
def run # rubocop:disable all
|
64
|
+
begin
|
65
|
+
beanstalk = Beanstalk::Connection.new(
|
66
|
+
"#{config[:host]}:#{config[:port]}"
|
67
|
+
)
|
68
|
+
rescue => e
|
69
|
+
critical "Failed to connect: (#{e})"
|
70
|
+
end
|
71
|
+
|
72
|
+
if config[:tube]
|
73
|
+
begin
|
74
|
+
stats = beanstalk.stats_tube(config[:tube])
|
75
|
+
rescue Beanstalk::NotFoundError
|
76
|
+
warning "Tube #{config[:tube]} not found"
|
77
|
+
end
|
78
|
+
else
|
79
|
+
stats = beanstalk.stats
|
80
|
+
end
|
81
|
+
|
82
|
+
unknown "#{config[:stat]} doesn't exist" unless stats.key?(config[:stat])
|
83
|
+
s = stats[config[:stat]].to_i
|
84
|
+
|
85
|
+
if config[:crit_high] && s > config[:crit_high]
|
86
|
+
critical "Too many #{config[:stat]} #{config[:crit_high]} (#{s} found)"
|
87
|
+
elsif config[:warn_high] && s > config[:warn_high]
|
88
|
+
warning "Too many #{config[:stat]} #{config[:warn_high]} jobs (#{s} found)"
|
89
|
+
elsif s < config[:crit_low]
|
90
|
+
warning "Not enough #{config[:stat]} #{config[:crit_low]} jobs (#{s} found)"
|
91
|
+
elsif s < config[:warn_low]
|
92
|
+
warning "Not enough #{config[:stat]} #{config[:warn_low]} (#{s} found)"
|
93
|
+
else
|
94
|
+
ok "#{s} #{config[:stat]} found."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-beanstalk-watchers-to-buried
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# #YELLOW
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: beanstalk
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# #YELLOW
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright S. Zachariah Sprackett <zac@sprackett.com>
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
require 'beanstalk-client'
|
31
|
+
|
32
|
+
#
|
33
|
+
# Check Beanstalk Watchers To Buried
|
34
|
+
#
|
35
|
+
class CheckBeanstalkWatchersToBuried < Sensu::Plugin::Check::CLI
|
36
|
+
option :host,
|
37
|
+
short: '-H HOST',
|
38
|
+
default: 'localhost'
|
39
|
+
option :port,
|
40
|
+
short: '-p PORT',
|
41
|
+
default: '11300'
|
42
|
+
option :tube,
|
43
|
+
short: '-t TUBE'
|
44
|
+
option :crit,
|
45
|
+
short: '-c CRIT_THRESHOLD',
|
46
|
+
proc: proc(&:to_i),
|
47
|
+
default: 0
|
48
|
+
option :warn,
|
49
|
+
short: '-w WARN_THRESHOLD',
|
50
|
+
proc: proc(&:to_i),
|
51
|
+
default: 0
|
52
|
+
|
53
|
+
def run # rubocop:disable all
|
54
|
+
unknown 'Tube was not set' unless config[:tube]
|
55
|
+
begin
|
56
|
+
beanstalk = Beanstalk::Connection.new(
|
57
|
+
"#{config[:host]}:#{config[:port]}"
|
58
|
+
)
|
59
|
+
rescue => e
|
60
|
+
critical "Failed to connect: (#{e})"
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
stats = beanstalk.stats_tube(config[:tube])
|
65
|
+
watchers = stats['current-watching'].to_i
|
66
|
+
buried = stats['current-jobs-buried'].to_i
|
67
|
+
rescue Beanstalk::NotFoundError
|
68
|
+
warning "Tube #{config[:tube]} not found"
|
69
|
+
end
|
70
|
+
# #YELLOW
|
71
|
+
unless watchers # rubocop:disable IfUnlessModifier
|
72
|
+
watchers = 0
|
73
|
+
end
|
74
|
+
|
75
|
+
if config[:crit] || (buried - watchers) > config[:crit]
|
76
|
+
critical "Exceeded buried jobs by threshold of #{config[:crit]} (#{watchers}/#{buried})"
|
77
|
+
elsif config[:warn] || (buried - watchers) > config[:warn]
|
78
|
+
warning "Exceeded buried jobs by threshold of #{config[:warn]} (#{watchers}/#{buried})"
|
79
|
+
else
|
80
|
+
ok "#{buried} buried jobs and #{watchers} watchers found."
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-beanstalk-watchers
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# #YELLOW
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: beanstalk
|
16
|
+
# gem: sensu-plugin
|
17
|
+
#
|
18
|
+
# USAGE:
|
19
|
+
# #YELLOW
|
20
|
+
#
|
21
|
+
# NOTES:
|
22
|
+
#
|
23
|
+
# LICENSE:
|
24
|
+
# Copyright S. Zachariah Sprackett <zac@sprackett.com>
|
25
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
26
|
+
# for details.
|
27
|
+
#
|
28
|
+
|
29
|
+
require 'sensu-plugin/check/cli'
|
30
|
+
require 'beanstalk-client'
|
31
|
+
|
32
|
+
#
|
33
|
+
# Check Beanstalk Watchers
|
34
|
+
#
|
35
|
+
class CheckBeanstalkWatchers < Sensu::Plugin::Check::CLI
|
36
|
+
option :host,
|
37
|
+
short: '-H HOST',
|
38
|
+
default: 'localhost'
|
39
|
+
option :port,
|
40
|
+
short: '-p PORT',
|
41
|
+
default: '11300'
|
42
|
+
option :tube,
|
43
|
+
short: '-t TUBE'
|
44
|
+
option :crit,
|
45
|
+
short: '-c CRIT_THRESHOLD',
|
46
|
+
proc: proc(&:to_i),
|
47
|
+
default: false
|
48
|
+
option :warn,
|
49
|
+
short: '-w WARN_THRESHOLD',
|
50
|
+
proc: proc(&:to_i),
|
51
|
+
default: false
|
52
|
+
|
53
|
+
def run # rubocop:disable all
|
54
|
+
unknown 'Tube was not set' unless config[:tube]
|
55
|
+
begin
|
56
|
+
beanstalk = Beanstalk::Connection.new(
|
57
|
+
"#{config[:host]}:#{config[:port]}"
|
58
|
+
)
|
59
|
+
rescue => e
|
60
|
+
critical "Failed to connect: (#{e})"
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
stats = beanstalk.stats_tube(config[:tube])
|
65
|
+
watchers = stats['current-watching'].to_i
|
66
|
+
rescue Beanstalk::NotFoundError
|
67
|
+
warning "Tube #{config[:tube]} not found"
|
68
|
+
end
|
69
|
+
# #YELLOW
|
70
|
+
unless watchers # rubocop:disable IfUnlessModifier
|
71
|
+
watchers = 0
|
72
|
+
end
|
73
|
+
if config[:crit] && watchers < config[:crit]
|
74
|
+
critical "Required at least #{config[:crit]} watchers but have #{watchers}"
|
75
|
+
elsif config[:warn] && watchers < config[:warn]
|
76
|
+
warning "Required at least #{config[:warn]} watchers but have #{watchers}"
|
77
|
+
else
|
78
|
+
ok "#{watchers} watchers found."
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-beanstalkd
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Check beanstalkd queues
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# plain-text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: beaneater
|
16
|
+
# gem: json
|
17
|
+
# gem: sensu-plugin
|
18
|
+
#
|
19
|
+
# USAGE:
|
20
|
+
# #YELLOW
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2014 99designs, Inc <devops@99designs.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 'json'
|
32
|
+
require 'beaneater'
|
33
|
+
|
34
|
+
#
|
35
|
+
# Checks the queue levels
|
36
|
+
#
|
37
|
+
class BeanstalkdQueuesStatus < Sensu::Plugin::Check::CLI
|
38
|
+
check_name 'beanstalkd queues check'
|
39
|
+
|
40
|
+
option :tube,
|
41
|
+
short: '-t name',
|
42
|
+
long: '--tube name',
|
43
|
+
description: 'Name of the tube to check',
|
44
|
+
default: 'default'
|
45
|
+
|
46
|
+
option :server,
|
47
|
+
description: 'beanstalkd server',
|
48
|
+
short: '-s SERVER',
|
49
|
+
long: '--server SERVER',
|
50
|
+
default: 'localhost'
|
51
|
+
|
52
|
+
option :port,
|
53
|
+
description: 'beanstalkd server port',
|
54
|
+
short: '-p PORT',
|
55
|
+
long: '--port PORT',
|
56
|
+
default: '11300'
|
57
|
+
|
58
|
+
option :ready,
|
59
|
+
description: 'ready tasks WARNING/CRITICAL thresholds',
|
60
|
+
short: '-r W,C',
|
61
|
+
long: '--ready-tasks W,C',
|
62
|
+
proc: proc { |a| a.split(',', 2).map(&:to_i) },
|
63
|
+
default: [6000, 8000]
|
64
|
+
|
65
|
+
option :urgent,
|
66
|
+
description: 'urgent tasks WARNING/CRITICAL thresholds',
|
67
|
+
short: '-u W,C',
|
68
|
+
long: '--urgent-tasks W,C',
|
69
|
+
proc: proc { |a| a.split(',', 2).map(&:to_i) },
|
70
|
+
default: [2000, 3000]
|
71
|
+
|
72
|
+
option :buried,
|
73
|
+
description: 'buried tasks WARNING/CRITICAL thresholds',
|
74
|
+
short: '-b W,C',
|
75
|
+
long: '--buried-tasks W,C',
|
76
|
+
proc: proc { |a| a.split(',', 2).map(&:to_i) },
|
77
|
+
default: [30, 60]
|
78
|
+
|
79
|
+
def acquire_beanstalkd_connection
|
80
|
+
begin
|
81
|
+
conn = Beaneater::Pool.new(["#{config[:server]}:#{config[:port]}"])
|
82
|
+
rescue
|
83
|
+
warning 'could not connect to beanstalkd'
|
84
|
+
end
|
85
|
+
conn
|
86
|
+
end
|
87
|
+
|
88
|
+
def run # rubocop:disable all
|
89
|
+
stats = acquire_beanstalkd_connection.tubes["#{config[:tube]}"].stats
|
90
|
+
message 'All queues are healthy'
|
91
|
+
|
92
|
+
warns, crits, msg = check_queues(stats)
|
93
|
+
msg.join("\n")
|
94
|
+
|
95
|
+
if crits.size > 0
|
96
|
+
message msg
|
97
|
+
critical
|
98
|
+
end
|
99
|
+
|
100
|
+
if warns.size > 0
|
101
|
+
message msg
|
102
|
+
warning
|
103
|
+
end
|
104
|
+
ok
|
105
|
+
end
|
106
|
+
|
107
|
+
def check_queues(stats) # rubocop:disable all
|
108
|
+
msg = []
|
109
|
+
crits = {}
|
110
|
+
warns = {}
|
111
|
+
|
112
|
+
[:ready, :urgent, :buried].each do |task|
|
113
|
+
tasks = stats.send("current_jobs_#{task}".to_sym)
|
114
|
+
|
115
|
+
if tasks > config[task][1]
|
116
|
+
crits[task] = tasks
|
117
|
+
msg << task.to_s + " queue has #{tasks} items"
|
118
|
+
next
|
119
|
+
end
|
120
|
+
|
121
|
+
if tasks > config[task][0]
|
122
|
+
warns[task] = tasks
|
123
|
+
msg << task.to_s + " queue has #{tasks} items"
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
[warns, crits, msg]
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# beanstalkd-metrics
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks the beanstalkd stats, using the beaneater gem
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# metric-data
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: beaneater
|
16
|
+
# gem: json
|
17
|
+
# gem: sensu-plugin
|
18
|
+
#
|
19
|
+
# USAGE:
|
20
|
+
# #YELLOW
|
21
|
+
#
|
22
|
+
# NOTES:
|
23
|
+
#
|
24
|
+
# LICENSE:
|
25
|
+
# Copyright 2014 99designs, Inc <devops@99designs.com>
|
26
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
27
|
+
# for details.
|
28
|
+
#
|
29
|
+
|
30
|
+
require 'sensu-plugin/metric/cli'
|
31
|
+
require 'json'
|
32
|
+
require 'beaneater'
|
33
|
+
|
34
|
+
#
|
35
|
+
# Checks the queue levels
|
36
|
+
#
|
37
|
+
class BeanstalkdMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
38
|
+
option :server,
|
39
|
+
description: 'beanstalkd server',
|
40
|
+
short: '-s SERVER',
|
41
|
+
long: '--server SERVER',
|
42
|
+
default: 'localhost'
|
43
|
+
|
44
|
+
option :port,
|
45
|
+
description: 'beanstalkd server port',
|
46
|
+
short: '-p PORT',
|
47
|
+
long: '--port PORT',
|
48
|
+
default: '11300'
|
49
|
+
|
50
|
+
option :scheme,
|
51
|
+
description: 'Metric naming scheme, text to prepend to metric',
|
52
|
+
short: '-s SCHEME',
|
53
|
+
long: '--scheme SCHEME',
|
54
|
+
default: "#{Socket.gethostname}.beanstalkd"
|
55
|
+
|
56
|
+
def acquire_beanstalkd_connection
|
57
|
+
begin
|
58
|
+
conn = Beaneater::Pool.new(["#{config[:server]}:#{config[:port]}"])
|
59
|
+
rescue
|
60
|
+
warning 'could not connect to beanstalkd'
|
61
|
+
end
|
62
|
+
conn
|
63
|
+
end
|
64
|
+
|
65
|
+
def run
|
66
|
+
stats = acquire_beanstalkd_connection.stats
|
67
|
+
|
68
|
+
stats.keys.sort.each do |key|
|
69
|
+
next if key == 'version' # The version X.Y.Z is not a number
|
70
|
+
output "#{config[:scheme]}.#{key}", stats.public_send(key)
|
71
|
+
end
|
72
|
+
|
73
|
+
ok
|
74
|
+
end
|
75
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,261 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-beanstalk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yieldbot, Inc. and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
|
14
|
+
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
|
15
|
+
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
|
16
|
+
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
|
17
|
+
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
|
18
|
+
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
|
19
|
+
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
|
20
|
+
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
|
21
|
+
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
|
22
|
+
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
|
23
|
+
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
24
|
+
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
|
25
|
+
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
|
26
|
+
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
|
27
|
+
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
|
28
|
+
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
|
29
|
+
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
|
30
|
+
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
|
+
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-04-07 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: json
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.8.2
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.8.2
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: sensu-plugin
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.1.0
|
56
|
+
type: :runtime
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.0
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: beanstalk-client
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.1
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.1.1
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: beaneater
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.3.3
|
84
|
+
type: :runtime
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.3.3
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: codeclimate-test-reporter
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.4'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.4'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: rubocop
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 0.17.0
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.17.0
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rspec
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '3.1'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '3.1'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: bundler
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '1.7'
|
140
|
+
type: :development
|
141
|
+
prerelease: false
|
142
|
+
version_requirements: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '1.7'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: rake
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '10.0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - "~>"
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '10.0'
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: github-markup
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '1.3'
|
168
|
+
type: :development
|
169
|
+
prerelease: false
|
170
|
+
version_requirements: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '1.3'
|
175
|
+
- !ruby/object:Gem::Dependency
|
176
|
+
name: redcarpet
|
177
|
+
requirement: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - "~>"
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '3.2'
|
182
|
+
type: :development
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '3.2'
|
189
|
+
- !ruby/object:Gem::Dependency
|
190
|
+
name: yard
|
191
|
+
requirement: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '0.8'
|
196
|
+
type: :development
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - "~>"
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0.8'
|
203
|
+
- !ruby/object:Gem::Dependency
|
204
|
+
name: pry
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - "~>"
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0.10'
|
210
|
+
type: :development
|
211
|
+
prerelease: false
|
212
|
+
version_requirements: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - "~>"
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0.10'
|
217
|
+
description: Sensu plugins for beanstalk
|
218
|
+
email: "<sensu-users@googlegroups.com>"
|
219
|
+
executables: []
|
220
|
+
extensions: []
|
221
|
+
extra_rdoc_files: []
|
222
|
+
files:
|
223
|
+
- CHANGELOG.md
|
224
|
+
- LICENSE
|
225
|
+
- README.md
|
226
|
+
- bin/check-beanstalk-jobs.rb
|
227
|
+
- bin/check-beanstalk-statistic.rb
|
228
|
+
- bin/check-beanstalk-watchers-to-buried.rb
|
229
|
+
- bin/check-beanstalk-watchers.rb
|
230
|
+
- bin/check-beanstalkd.rb
|
231
|
+
- bin/metrics-beanstalkd.rb
|
232
|
+
- lib/sensu-plugins-beanstalk.rb
|
233
|
+
homepage: https://github.com/sensu-plugins/sensu-plugins-beanstalk
|
234
|
+
licenses:
|
235
|
+
- MIT
|
236
|
+
metadata:
|
237
|
+
maintainer: ''
|
238
|
+
development_status: unmaintained
|
239
|
+
production_status: unstable - testing reccomended
|
240
|
+
post_install_message:
|
241
|
+
rdoc_options: []
|
242
|
+
require_paths:
|
243
|
+
- lib
|
244
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
245
|
+
requirements:
|
246
|
+
- - ">="
|
247
|
+
- !ruby/object:Gem::Version
|
248
|
+
version: 1.9.3
|
249
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
|
+
requirements:
|
251
|
+
- - ">"
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: 1.3.1
|
254
|
+
requirements: []
|
255
|
+
rubyforge_project:
|
256
|
+
rubygems_version: 2.2.2
|
257
|
+
signing_key:
|
258
|
+
specification_version: 4
|
259
|
+
summary: Sensu plugins for beanstalk
|
260
|
+
test_files: []
|
261
|
+
has_rdoc:
|
metadata.gz.sig
ADDED