sensu-plugins-storm 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -3
- data/README.md +7 -0
- data/bin/check-storm-capacity.rb +108 -0
- data/bin/check-storm-topologies.rb +17 -7
- data/lib/sensu-plugins-storm/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3b87c6eddd1a19b6b85786b8c5e51947590ae63
|
4
|
+
data.tar.gz: d3573bd025d139712f9ca6256fe589bb0c827670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 296978b96f0e1959b6d9ade1be38db5c57d671c9123a85b8e344e7445a6f7a4d4ce4b7b32f5493731747c1ea50d285c917c7a2fce1f342a70b9c55e17a77eeb5
|
7
|
+
data.tar.gz: 495830c6b61fdb3d47b27195882ba3308b9ff49b517f6135097236b107d3346874c1c839cf84afc99d43e8e52ceafd1fa8f3761ff4421c1064c6ecdbb81552a0
|
data/CHANGELOG.md
CHANGED
@@ -3,9 +3,13 @@ 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
|
-
|
7
|
-
|
6
|
+
# 0.2.0 - 2016-09-01
|
7
|
+
### Added
|
8
|
+
- check-storm-capacity script
|
9
|
+
|
10
|
+
# 0.1.0 - 2016-09-01
|
8
11
|
### Added
|
9
12
|
- initial release
|
10
13
|
|
11
|
-
[
|
14
|
+
[0.2.0]: https://github.com/andyroyle/sensu-plugins-storm/compare/0.0.2...HEAD
|
15
|
+
[0.1.0]: https://github.com/andyroyle/sensu-plugins-storm/compare/0.0.1...0.0.2
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
## Files
|
11
11
|
* bin/check-storm-topologies.rb
|
12
|
+
* bin/check-storm-capacity.rb
|
12
13
|
|
13
14
|
## Usage
|
14
15
|
|
@@ -17,6 +18,12 @@
|
|
17
18
|
/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
|
18
19
|
```
|
19
20
|
|
21
|
+
|
22
|
+
**check-storm-capacity** example
|
23
|
+
```bash
|
24
|
+
/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
|
25
|
+
```
|
26
|
+
|
20
27
|
## Installation
|
21
28
|
|
22
29
|
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
@@ -0,0 +1,108 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Storm Capacity 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 capacity of all running bolts (in all topologies) and compare to crit/warn 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 CheckStormTopologies < Sensu::Plugin::Check::CLI
|
21
|
+
option :host,
|
22
|
+
short: '-h',
|
23
|
+
long: '--host=VALUE',
|
24
|
+
description: 'Cluster host'
|
25
|
+
|
26
|
+
option :user,
|
27
|
+
short: '-u',
|
28
|
+
long: '--username=VALUE',
|
29
|
+
description: 'username'
|
30
|
+
|
31
|
+
option :pass,
|
32
|
+
short: '-p',
|
33
|
+
long: '--password=VALUE',
|
34
|
+
description: 'password'
|
35
|
+
|
36
|
+
option :ssl,
|
37
|
+
description: 'use HTTPS (default false)',
|
38
|
+
long: '--ssl'
|
39
|
+
|
40
|
+
option :crit,
|
41
|
+
short: '-c',
|
42
|
+
long: '--critical=VALUE',
|
43
|
+
description: 'Critical threshold'
|
44
|
+
|
45
|
+
option :warn,
|
46
|
+
short: '-w',
|
47
|
+
long: '--warn=VALUE',
|
48
|
+
description: 'Warn threshold'
|
49
|
+
|
50
|
+
option :timeout,
|
51
|
+
short: '-t',
|
52
|
+
long: '--timeout=VALUE',
|
53
|
+
description: 'Timeout in seconds',
|
54
|
+
default: 5
|
55
|
+
|
56
|
+
def request(path)
|
57
|
+
protocol = config[:ssl] ? 'https' : 'http'
|
58
|
+
auth = Base64.encode64("#{config[:user]}:#{config[:pass]}")
|
59
|
+
RestClient::Request.execute(
|
60
|
+
method: :get,
|
61
|
+
url: "#{protocol}://#{config[:host]}:#{config[:port]}/#{path}",
|
62
|
+
timeout: config[:timeout],
|
63
|
+
headers: { 'Authorization' => "Basic #{auth}" }
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def run
|
68
|
+
critical_usage = config[:crit].to_f
|
69
|
+
warn_usage = config[:warn].to_f
|
70
|
+
|
71
|
+
if [config[:host], config[:user], config[:pass]].any?(&:nil?)
|
72
|
+
unknown 'Must specify host, user and password'
|
73
|
+
end
|
74
|
+
|
75
|
+
r = request('/stormui/api/v1/topology/summary')
|
76
|
+
|
77
|
+
if r.code != 200
|
78
|
+
critical "unexpected status code '#{r.code}'"
|
79
|
+
end
|
80
|
+
|
81
|
+
topologies = JSON.parse(r.to_str)['topologies']
|
82
|
+
topologies.each do |topology|
|
83
|
+
t = request("/stormui/api/v1/topology/#{topology['id']}")
|
84
|
+
if t.code != 200
|
85
|
+
critical "unexpected status code '#{r.code}'"
|
86
|
+
end
|
87
|
+
|
88
|
+
bolts = JSON.parse(t.to_str)['bolts']
|
89
|
+
bolts.each do |bolt|
|
90
|
+
capacity = bolt['capacity'].to_f
|
91
|
+
if capacity > critical_usage
|
92
|
+
critical "bolt #{bolt['boltId']} has capacity #{bolt['capacity']}"
|
93
|
+
elsif capacity > warn_usage
|
94
|
+
warn "bolt #{bolt['boltId']} has capacity #{bolt['capacity']}"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
ok 'all capacities ok'
|
99
|
+
end
|
100
|
+
|
101
|
+
rescue Errno::ECONNREFUSED => e
|
102
|
+
critical 'Storm is not responding' + e.message
|
103
|
+
rescue RestClient::RequestTimeout
|
104
|
+
critical 'Storm Connection timed out'
|
105
|
+
rescue StandardError => e
|
106
|
+
unknown 'An exception occurred:' + e.message
|
107
|
+
end
|
108
|
+
end
|
@@ -15,6 +15,7 @@ require 'rest-client'
|
|
15
15
|
require 'openssl'
|
16
16
|
require 'uri'
|
17
17
|
require 'json'
|
18
|
+
require 'base64'
|
18
19
|
|
19
20
|
class CheckStormTopologies < Sensu::Plugin::Check::CLI
|
20
21
|
option :host,
|
@@ -47,23 +48,32 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
|
|
47
48
|
long: '--expect=VALUE',
|
48
49
|
description: 'Match exactly the nuber of topologies'
|
49
50
|
|
50
|
-
|
51
|
+
option :timeout,
|
52
|
+
short: '-t',
|
53
|
+
long: '--timeout=VALUE',
|
54
|
+
description: 'Timeout in seconds',
|
55
|
+
default: 5
|
56
|
+
|
57
|
+
def request(path)
|
51
58
|
protocol = config[:ssl] ? 'https' : 'http'
|
52
|
-
|
59
|
+
auth = Base64.encode64("#{config[:user]}:#{config[:pass]}")
|
60
|
+
RestClient::Request.execute(
|
61
|
+
method: :get,
|
62
|
+
url: "#{protocol}://#{config[:host]}:#{config[:port]}/#{path}",
|
63
|
+
timeout: config[:timeout],
|
64
|
+
headers: { 'Authorization' => "Basic #{auth}" }
|
65
|
+
)
|
53
66
|
end
|
54
67
|
|
55
68
|
def run
|
56
|
-
user = config[:user]
|
57
|
-
pass = config[:pass]
|
58
|
-
host = config[:host]
|
59
69
|
critical_usage = config[:crit].to_f
|
60
70
|
expect = config[:expect].to_f
|
61
71
|
|
62
|
-
if [host, user, pass].any?(&:nil?)
|
72
|
+
if [config[:host], config[:user], config[:pass]].any?(&:nil?)
|
63
73
|
unknown 'Must specify host, user and password'
|
64
74
|
end
|
65
75
|
|
66
|
-
r = request('/stormui/api/v1/topology/summary'
|
76
|
+
r = request('/stormui/api/v1/topology/summary')
|
67
77
|
|
68
78
|
if r.code != 200
|
69
79
|
critical "unexpected status code '#{r.code}'"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-storm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Royle
|
@@ -167,10 +167,12 @@ dependencies:
|
|
167
167
|
description: This plugin provides metrics and checks for Apache Storm topologies
|
168
168
|
email: <ajroyle@gmail.com>
|
169
169
|
executables:
|
170
|
+
- check-storm-capacity.rb
|
170
171
|
- check-storm-topologies.rb
|
171
172
|
extensions: []
|
172
173
|
extra_rdoc_files: []
|
173
174
|
files:
|
175
|
+
- bin/check-storm-capacity.rb
|
174
176
|
- bin/check-storm-topologies.rb
|
175
177
|
- lib/sensu-plugins-storm/version.rb
|
176
178
|
- lib/sensu-plugins-storm.rb
|