sensu-plugins-storm 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16b02fc7597faffce4fe00c4319627f0ab821085
4
- data.tar.gz: 0be11f83aeefa0b3d21574c90d2d4be3d8529b48
3
+ metadata.gz: 1890e59e02fd0ab62bd5440b455401c716df56bf
4
+ data.tar.gz: 014b252d57189836d61929056a80b3f7e6899b82
5
5
  SHA512:
6
- metadata.gz: a2a908dea2955f86e2e313b56522e222ae8a98c7cbf8f49c76cc2fb00eaf136563d7d0e1d377db646b30beb4db174322646177fc925486c568891d75f21c575f
7
- data.tar.gz: f40992729808d0da2f3923cb09898fd6fe837f4c9c402a8604d3e2286d8825d44d5b7708fd17f4a7ac4a969e67fd36344971becd518e84f85b6b70b12e4bdc2f
6
+ metadata.gz: e241dc326e76b78e2054ac391bf3981cb8f1f38449187ddcd4e5607d59a5b522eb9c869771e03b6a2ae1b82c62a1b6d505d793ee0cd3155b43418296549ad1ea
7
+ data.tar.gz: 1a0fcfe22df5f458f9467c0013bdf23e0ee0299adcfa37ee97d703ea2330bdb53e3bbcd9d4e3fc82faa4386d6e14e6d879dd6101f20e2e7fdd73443104d11b56
data/README.md CHANGED
@@ -10,6 +10,7 @@
10
10
  ## Files
11
11
  * bin/check-storm-topologies.rb
12
12
  * bin/check-storm-capacity.rb
13
+ * bin/check-storm-workers.rb
13
14
  * bin/metrics-storm-topologies.rb
14
15
 
15
16
  ## Usage
@@ -19,17 +20,20 @@
19
20
  /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-storm-topologies.rb --host=my-storm-cluster.com -s --user=admin --password=password --expect=1
20
21
  ```
21
22
 
22
-
23
23
  **check-storm-capacity** example
24
24
  ```bash
25
25
  /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-storm-capacity.rb --host=my-storm-cluster.com -s --user=admin --password=password -w 1 -c 1.5
26
26
  ```
27
27
 
28
- **check-storm-capacity** example
28
+ **check-storm-workers** example
29
29
  ```bash
30
- /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby metrics-storm-topologies.rb --host=my-storm-cluster.com -s --user=admin --password=password
30
+ /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-storm-workers.rb --host=my-storm-cluster.com -s --user=admin --password=password -m 3 -w 4
31
31
  ```
32
32
 
33
+ **metrics-storm-topologies** example
34
+ ```bash
35
+ /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby metrics-storm-topologies.rb --host=my-storm-cluster.com -s --user=admin --password=password
36
+ ```
33
37
 
34
38
  ## Installation
35
39
 
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Storm Workers Check
4
+ # ===
5
+ #
6
+ # Copyright 2016 Andy Royle <ajroyle@gmail.com>
7
+ #
8
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
9
+ # for details.
10
+ #
11
+ # Check the number of workers (supervisors) for a given cluster and compare to warn/minimum thresholds
12
+
13
+ require 'sensu-plugin/check/cli'
14
+ require 'rest-client'
15
+ require 'openssl'
16
+ require 'uri'
17
+ require 'json'
18
+ require 'base64'
19
+
20
+ class CheckStormCapacity < Sensu::Plugin::Check::CLI
21
+ option :host,
22
+ short: '-h',
23
+ long: '--host=VALUE',
24
+ description: 'Cluster host',
25
+ default: 'localhost'
26
+
27
+ option :user,
28
+ short: '-u',
29
+ long: '--username=VALUE',
30
+ description: 'username',
31
+ required: true
32
+
33
+ option :pass,
34
+ short: '-p',
35
+ long: '--password=VALUE',
36
+ description: 'password',
37
+ required: true
38
+
39
+ option :ssl,
40
+ description: 'use HTTPS (default false)',
41
+ long: '--ssl'
42
+
43
+ option :crit,
44
+ short: '-m',
45
+ long: '--minimum=VALUE',
46
+ description: 'Minimum (critical) workers',
47
+ required: true,
48
+ proc: proc { |l| l.to_i }
49
+
50
+ option :warn,
51
+ short: '-w',
52
+ long: '--warn=VALUE',
53
+ description: 'Warn threshold',
54
+ required: true,
55
+ proc: proc { |l| l.to_i }
56
+
57
+ option :timeout,
58
+ short: '-t',
59
+ long: '--timeout=VALUE',
60
+ description: 'Timeout in seconds',
61
+ proc: proc { |l| l.to_i },
62
+ default: 5
63
+
64
+ def request(path)
65
+ protocol = config[:ssl] ? 'https' : 'http'
66
+ auth = Base64.encode64("#{config[:user]}:#{config[:pass]}")
67
+ RestClient::Request.execute(
68
+ method: :get,
69
+ url: "#{protocol}://#{config[:host]}:#{config[:port]}/#{path}",
70
+ timeout: config[:timeout],
71
+ headers: { 'Authorization' => "Basic #{auth}" }
72
+ )
73
+ end
74
+
75
+ def run
76
+ r = request('/api/v1/cluster/summary')
77
+
78
+ if r.code != 200
79
+ critical "unexpected status code '#{r.code}'"
80
+ end
81
+
82
+ cluster = JSON.parse(r.to_str)
83
+ workers = cluster['supervisors'].to_i
84
+
85
+ if workers < config[:crit]
86
+ critical "worker count #{workers} is below allowed minimum of #{config[:crit]}"
87
+ elsif workers < config[:warn]
88
+ warning "worker count #{workers} is below warn threshold of #{config[:warn]}"
89
+ end
90
+
91
+ ok 'worker count OK'
92
+
93
+ rescue Errno::ECONNREFUSED => e
94
+ critical 'Storm is not responding' + e.message
95
+ rescue RestClient::RequestTimeout
96
+ critical 'Storm Connection timed out'
97
+ rescue StandardError => e
98
+ unknown 'An exception occurred:' + e.message
99
+ end
100
+ end
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsStorm
2
2
  module Version
3
- MAJOR = 0
4
- MINOR = 4
3
+ MAJOR = 1
4
+ MINOR = 0
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-storm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Royle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-16 00:00:00.000000000 Z
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -169,12 +169,14 @@ email: <ajroyle@gmail.com>
169
169
  executables:
170
170
  - check-storm-capacity.rb
171
171
  - check-storm-topologies.rb
172
+ - check-storm-workers.rb
172
173
  - metrics-storm-topologies.rb
173
174
  extensions: []
174
175
  extra_rdoc_files: []
175
176
  files:
176
177
  - bin/check-storm-capacity.rb
177
178
  - bin/check-storm-topologies.rb
179
+ - bin/check-storm-workers.rb
178
180
  - bin/metrics-storm-topologies.rb
179
181
  - lib/sensu-plugins-storm/version.rb
180
182
  - lib/sensu-plugins-storm.rb
@@ -207,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
209
  version: '0'
208
210
  requirements: []
209
211
  rubyforge_project:
210
- rubygems_version: 2.0.14
212
+ rubygems_version: 2.0.14.1
211
213
  signing_key:
212
214
  specification_version: 4
213
215
  summary: Sensu plugins for Storm