sensu-plugins-gearman 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c31abbd13408b9620448f62b8ce035b68e675f5e
4
+ data.tar.gz: fe94ebcc00ba5209439429404d881eab3efa85d1
5
+ SHA512:
6
+ metadata.gz: ce985ea100cdcf400422cc68f6c91d9c7f2da0fadde8f820d8aea80d67da53f546ceb09e0b655f675c0970bd8ec87cd4a032d36409351dde792e063bc1a0dbcf
7
+ data.tar.gz: 1c421fe62a05fde1931a51aa5970e3b602a37277e4d4214a4d5c173a1960ec66a99f0ede02bf63ff33e9c19ff4bfd62491777ea121a7ab7545445b9f75ff9db5
@@ -0,0 +1,6 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ ## 0.0.1 - 2016-03-11
5
+ ### Added
6
+ - Initial release
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Sensu-Plugins
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.
@@ -0,0 +1,24 @@
1
+ ## Sensu-Plugins-Gearman
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-gearman.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-gearman)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-gearman.svg)](http://badge.fury.io/rb/sensu-plugins-gearman)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-gearman/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-gearman)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-gearman/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-gearman)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-gearman.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-gearman)
8
+
9
+ ## Functionality
10
+
11
+ ## Files
12
+
13
+ * bin/metrics-gearman.rb
14
+ * bin/check-gearman-jobs.rb
15
+ * bin/check-gearman-workers.rb
16
+
17
+ ## Usage
18
+
19
+ ## Installation
20
+
21
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
22
+
23
+
24
+ ## Notes
@@ -0,0 +1,110 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-gearman-jobs
4
+ #
5
+ # DESCRIPTION:
6
+ # #YELLOW
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: gearman-ruby
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2016 Aaron Brady <aaron@iweb.co.uk>
25
+ # Copyright S. Zachariah Sprackett <zac@sprackett.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 'gearman/server'
32
+
33
+ #
34
+ # Check Gearman Workers
35
+ #
36
+ class CheckGearmanWorkers < Sensu::Plugin::Check::CLI
37
+ option :host,
38
+ short: '-H HOST',
39
+ default: 'localhost'
40
+ option :port,
41
+ short: '-p PORT',
42
+ default: '4730'
43
+ option :queue,
44
+ short: '-q QUEUE'
45
+ option :crit_high,
46
+ short: '-c CRIT_HIGH_THRESHOLD',
47
+ proc: proc(&:to_i),
48
+ default: false
49
+ option :warn_high,
50
+ short: '-w WARN_HIGH_THRESHOLD',
51
+ proc: proc(&:to_i),
52
+ default: false
53
+ option :crit_low,
54
+ short: '-C CRIT_LOW_THRESHOLD',
55
+ proc: proc(&:to_i),
56
+ default: 0
57
+ option :warn_low,
58
+ short: '-W WARN_LOW_THRESHOLD',
59
+ proc: proc(&:to_i),
60
+ default: 0
61
+
62
+ def run
63
+ begin
64
+ gearman = Gearman::Server.new(
65
+ "#{config[:host]}:#{config[:port]}"
66
+ )
67
+ rescue => e
68
+ critical "Failed to connect: (#{e})"
69
+ end
70
+
71
+ stats = {}
72
+ criticals = []
73
+ warnings = []
74
+ okays = []
75
+
76
+ if config[:queue]
77
+ stat = gearman.status[config[:queue]]
78
+ if stat.nil?
79
+ warning "Queue #{config[:queue]} not found"
80
+ else
81
+ stats = { config[:queue] => stat }
82
+ end
83
+ else
84
+ stats = gearman.status
85
+ end
86
+
87
+ stats.each do |queue_name, single_stat|
88
+ jobs = single_stat[:queue].to_i
89
+ if config[:crit_high] && jobs > config[:crit_high]
90
+ criticals << "#{queue_name}: High threshold is #{config[:crit_high]} jobs (#{jobs} active jobs)"
91
+ elsif config[:warn_high] && jobs > config[:warn_high]
92
+ warnings << "#{queue_name}: High threshold is #{config[:warn_high]} jobs (#{jobs} active jobs)"
93
+ elsif jobs < config[:crit_low]
94
+ criticals << "#{queue_name}: Low threshold is #{config[:crit_low]} jobs (#{jobs} active jobs)"
95
+ elsif jobs < config[:warn_low]
96
+ warnings << "#{queue_name}: Low threshold is #{config[:warn_low]} (#{jobs} active jobs)"
97
+ else
98
+ okays << "#{queue_name}: #{jobs} jobs found."
99
+ end
100
+ end
101
+
102
+ unless criticals.empty?
103
+ critical criticals.join(' ')
104
+ end
105
+ unless warnings.empty?
106
+ warning warnings.join(' ')
107
+ end
108
+ ok okays.join(' ')
109
+ end
110
+ end
@@ -0,0 +1,110 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-gearman-workers
4
+ #
5
+ # DESCRIPTION:
6
+ # #YELLOW
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: gearman-ruby
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2016 Aaron Brady <aaron@iweb.co.uk>
25
+ # Copyright S. Zachariah Sprackett <zac@sprackett.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 'gearman/server'
32
+
33
+ #
34
+ # Check Gearman Workers
35
+ #
36
+ class CheckGearmanWorkers < Sensu::Plugin::Check::CLI
37
+ option :host,
38
+ short: '-H HOST',
39
+ default: 'localhost'
40
+ option :port,
41
+ short: '-p PORT',
42
+ default: '4730'
43
+ option :queue,
44
+ short: '-q QUEUE'
45
+ option :crit_high,
46
+ short: '-c CRIT_HIGH_THRESHOLD',
47
+ proc: proc(&:to_i),
48
+ default: false
49
+ option :warn_high,
50
+ short: '-w WARN_HIGH_THRESHOLD',
51
+ proc: proc(&:to_i),
52
+ default: false
53
+ option :crit_low,
54
+ short: '-C CRIT_LOW_THRESHOLD',
55
+ proc: proc(&:to_i),
56
+ default: 0
57
+ option :warn_low,
58
+ short: '-W WARN_LOW_THRESHOLD',
59
+ proc: proc(&:to_i),
60
+ default: 0
61
+
62
+ def run
63
+ begin
64
+ gearman = Gearman::Server.new(
65
+ "#{config[:host]}:#{config[:port]}"
66
+ )
67
+ rescue => e
68
+ critical "Failed to connect: (#{e})"
69
+ end
70
+
71
+ stats = {}
72
+ criticals = []
73
+ warnings = []
74
+ okays = []
75
+
76
+ if config[:queue]
77
+ stat = gearman.status[config[:queue]]
78
+ if stat.nil?
79
+ warning "Queue #{config[:queue]} not found"
80
+ else
81
+ stats = { config[:queue] => stat }
82
+ end
83
+ else
84
+ stats = gearman.status
85
+ end
86
+
87
+ stats.each do |queue_name, single_stat|
88
+ workers = single_stat[:workers].to_i
89
+ if config[:crit_high] && workers > config[:crit_high]
90
+ criticals << "#{queue_name}: High threshold is #{config[:crit_high]} workers (#{workers} active workers)"
91
+ elsif config[:warn_high] && workers > config[:warn_high]
92
+ warnings << "#{queue_name}: High threshold is #{config[:warn_high]} workers (#{workers} active workers)"
93
+ elsif workers < config[:crit_low]
94
+ criticals << "#{queue_name}: Low threshold is #{config[:crit_low]} workers (#{workers} active workers)"
95
+ elsif workers < config[:warn_low]
96
+ warnings << "#{queue_name}: Low threshold is #{config[:warn_low]} (#{workers} active workers)"
97
+ else
98
+ okays << "#{queue_name}: #{workers} workers found."
99
+ end
100
+ end
101
+
102
+ unless criticals.empty?
103
+ critical criticals.join(' ')
104
+ end
105
+ unless warnings.empty?
106
+ warning warnings.join(' ')
107
+ end
108
+ ok okays.join(' ')
109
+ end
110
+ end
@@ -0,0 +1,82 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metrics-gearman
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin logs the gearman stats
7
+ #
8
+ # OUTPUT:
9
+ # metric-data
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: gearman-ruby
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # #YELLOW
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2016 Aaron Brady <aaron@iweb.co.uk>
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 'gearman/server'
33
+
34
+ #
35
+ # Check Gearman Queues
36
+ #
37
+ class GearmanMetrics < Sensu::Plugin::Metric::CLI::Graphite
38
+ option :host,
39
+ short: '-H HOST',
40
+ default: 'localhost'
41
+ option :port,
42
+ short: '-p PORT',
43
+ default: '4730'
44
+ option :queue,
45
+ short: '-q QUEUE'
46
+ option :scheme,
47
+ description: 'Metric naming scheme, text to prepend to metric',
48
+ short: '-s SCHEME',
49
+ long: '--scheme SCHEME',
50
+ default: "#{Socket.gethostname}.gearman"
51
+
52
+ def run
53
+ begin
54
+ gearman = Gearman::Server.new(
55
+ "#{config[:host]}:#{config[:port]}"
56
+ )
57
+ rescue => e
58
+ critical "Failed to connect: (#{e})"
59
+ end
60
+
61
+ stats = {}
62
+
63
+ if config[:queue]
64
+ stat = gearman.status[config[:queue]]
65
+ if stat.nil?
66
+ warning "Queue #{config[:queue]} not found"
67
+ else
68
+ stats = { config[:queue] => stat }
69
+ end
70
+ else
71
+ stats = gearman.status
72
+ end
73
+
74
+ stats.each do |key, counts|
75
+ counts.each do |count_key, count_value|
76
+ output "#{config[:scheme]}.#{key}.#{count_key}", count_value
77
+ end
78
+ end
79
+
80
+ ok
81
+ end
82
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-gearman/version'
@@ -0,0 +1,9 @@
1
+ module SensuPluginsGearman
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-gearman
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-12 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: gearman-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.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.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github-markup
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: redcarpet
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.37'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.37'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.8'
167
+ description: Sensu plugins for gearman
168
+ email: "<sensu-users@googlegroups.com>"
169
+ executables:
170
+ - check-gearman-jobs.rb
171
+ - metrics-gearman.rb
172
+ - check-gearman-workers.rb
173
+ extensions: []
174
+ extra_rdoc_files: []
175
+ files:
176
+ - CHANGELOG.md
177
+ - LICENSE
178
+ - README.md
179
+ - bin/check-gearman-jobs.rb
180
+ - bin/check-gearman-workers.rb
181
+ - bin/metrics-gearman.rb
182
+ - lib/sensu-plugins-gearman.rb
183
+ - lib/sensu-plugins-gearman/version.rb
184
+ homepage: https://github.com/sensu-plugins/sensu-plugins-gearman
185
+ licenses:
186
+ - MIT
187
+ metadata:
188
+ maintainer: sensu-plugin
189
+ development_status: active
190
+ production_status: unstable - testing recommended
191
+ release_draft: 'false'
192
+ release_prerelease: 'false'
193
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
194
+ in /etc/default/sensu
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ required_ruby_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 2.0.0
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ requirements: []
209
+ rubyforge_project:
210
+ rubygems_version: 2.4.5.1
211
+ signing_key:
212
+ specification_version: 4
213
+ summary: Sensu plugins for gearman
214
+ test_files: []