sensu-plugins-storm 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6653f256959833a2357ca4a6e3efda14dc66e6cc
4
+ data.tar.gz: 119cb6c56efd92b64ef702f9f0ba64f63504f179
5
+ SHA512:
6
+ metadata.gz: 4a83364a158399bd142d236d889087ef9047681226ee2c1eadc4d45156e3bd0f425911d8e47bb629c79f8f81a61d188aa9749b7e460c97aa6531cf27f4a5ebad
7
+ data.tar.gz: 7f7135867b45bc80d74dc6d6cba45571ef20476ac9a144aa4a4d07547b65a98be13877dd7c141e3ed16ac0ad65ddfeb3fa3cabc0320d18168fb7bd240b16f6a1
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ hange Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## [Unreleased]
7
+ # 0.0.1 - 2016-09-01
8
+ ### Added
9
+ - initial release
10
+
11
+ [Unreleased]: https://github.com/andyroyle/sensu-plugins-storm/compare/1.0.0...HEAD
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Andy Royle
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,25 @@
1
+ ## Sensu-Plugins-Storm
2
+
3
+ [ ![Build Status](https://travis-ci.org/andyroyle/sensu-plugins-storm.svg?branch=master)](https://travis-ci.org/andyroyle/sensu-plugins-storm)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-storm.svg)](http://badge.fury.io/rb/sensu-plugins-storm)
5
+ [![Code Climate](https://codeclimate.com/github/andyroyle/sensu-plugins-storm/badges/gpa.svg)](https://codeclimate.com/github/andyroyle/sensu-plugins-storm)
6
+ [![Test Coverage](https://codeclimate.com/github/andyroyle/sensu-plugins-storm/badges/coverage.svg)](https://codeclimate.com/github/andyroyle/sensu-plugins-storm)
7
+
8
+ ## Functionality
9
+
10
+ ## Files
11
+ * bin/check-storm-topologies.rb
12
+
13
+ ## Usage
14
+
15
+ **check-storm-topologies** example
16
+ ```bash
17
+ /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
+
20
+ ## Installation
21
+
22
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
23
+
24
+ ## Notes
25
+ The ruby executables are install in path similar to `/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-storm-0.1.0/bin`
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Storm Topology Count 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 running topologies and compare to warn/crit thresholds
12
+
13
+ require 'sensu-plugin/check/cli'
14
+ require 'rest-client'
15
+ require 'openssl'
16
+ require 'uri'
17
+ require 'json'
18
+
19
+ class CheckStormTopologies < Sensu::Plugin::Check::CLI
20
+ option :host,
21
+ short: '-h',
22
+ long: '--host=VALUE',
23
+ description: 'Cluster host'
24
+
25
+ option :user,
26
+ short: '-u',
27
+ long: '--username=VALUE',
28
+ description: 'username'
29
+
30
+ option :pass,
31
+ short: '-p',
32
+ long: '--password=VALUE',
33
+ description: 'password'
34
+
35
+ option :ssl,
36
+ description: 'use HTTPS (default false)',
37
+ long: '--ssl'
38
+
39
+ option :crit,
40
+ short: '-c',
41
+ long: '--critical=VALUE',
42
+ description: 'Critical threshold',
43
+ default: '0'
44
+
45
+ option :expect,
46
+ short: '-e',
47
+ long: '--expect=VALUE',
48
+ description: 'Match exactly the nuber of topologies'
49
+
50
+ def request(path, server)
51
+ protocol = config[:ssl] ? 'https' : 'http'
52
+ RestClient::Resource.new("#{protocol}://#{config[:user]}:#{config[:pass]}@#{server}:#{config[:port]}/#{path}", timeout: 5).get
53
+ end
54
+
55
+ def run
56
+ user = config[:user]
57
+ pass = config[:pass]
58
+ host = config[:host]
59
+ critical_usage = config[:crit].to_f
60
+ expect = config[:expect].to_f
61
+
62
+ if [host, user, pass].any?(&:nil?)
63
+ unknown 'Must specify host, user and password'
64
+ end
65
+
66
+ r = request('/stormui/api/v1/topology/summary', host)
67
+
68
+ if r.code != 200
69
+ critical "unexpected status code '#{r.code}'"
70
+ else
71
+ topologies = JSON.parse(r.to_str)['topologies'].count
72
+
73
+ if expect > 0 && topologies == expect
74
+ ok "Topologies: #{topologies}"
75
+ elsif expect > 0
76
+ critical "Topologies: #{topologies}"
77
+ end
78
+
79
+ if topologies <= critical_usage
80
+ critical "Topologies: #{topologies}"
81
+ else
82
+ ok "Topologies: #{topologies}"
83
+ end
84
+ end
85
+
86
+ rescue Errno::ECONNREFUSED => e
87
+ critical 'Storm is not responding' + e.message
88
+ rescue RestClient::RequestTimeout
89
+ critical 'Storm Connection timed out'
90
+ rescue StandardError => e
91
+ unknown 'An exception occurred:' + e.message
92
+ end
93
+ end
@@ -0,0 +1,9 @@
1
+ module SensuPluginsStorm
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 0
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-storm/version'
metadata ADDED
@@ -0,0 +1,210 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-storm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andy Royle
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-01 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: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
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.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
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: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: '3.1'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: '3.1'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 0.40.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 0.40.0
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: This plugin provides metrics and checks for Apache Storm topologies
168
+ email: <ajroyle@gmail.com>
169
+ executables:
170
+ - check-storm-topologies.rb
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - bin/check-storm-topologies.rb
175
+ - lib/sensu-plugins-storm/version.rb
176
+ - lib/sensu-plugins-storm.rb
177
+ - LICENSE
178
+ - README.md
179
+ - CHANGELOG.md
180
+ homepage: https://github.com/andyroyle/sensu-plugins-storm
181
+ licenses:
182
+ - MIT
183
+ metadata:
184
+ maintainer: andyroyle
185
+ development_status: active
186
+ production_status: unstable - testing recommended
187
+ release_draft: 'false'
188
+ release_prerelease: 'false'
189
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
190
+ in /etc/default/sensu
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - '>='
197
+ - !ruby/object:Gem::Version
198
+ version: 2.0.0
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - '>='
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubyforge_project:
206
+ rubygems_version: 2.0.14
207
+ signing_key:
208
+ specification_version: 4
209
+ summary: Sensu plugins for Storm
210
+ test_files: []