sensu-plugins-storm 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3b87c6eddd1a19b6b85786b8c5e51947590ae63
4
- data.tar.gz: d3573bd025d139712f9ca6256fe589bb0c827670
3
+ metadata.gz: 6c0fdcb0a9c62f171a02f5895fd3d9137e9b143f
4
+ data.tar.gz: 96e7ba98a36b6ddfbcf2f10f650206a2a414f298
5
5
  SHA512:
6
- metadata.gz: 296978b96f0e1959b6d9ade1be38db5c57d671c9123a85b8e344e7445a6f7a4d4ce4b7b32f5493731747c1ea50d285c917c7a2fce1f342a70b9c55e17a77eeb5
7
- data.tar.gz: 495830c6b61fdb3d47b27195882ba3308b9ff49b517f6135097236b107d3346874c1c839cf84afc99d43e8e52ceafd1fa8f3761ff4421c1064c6ecdbb81552a0
6
+ metadata.gz: 0eaf3b3e760a7a0638cfb3634e3fafa2246d34af19174ce01e344cbebc11f0981de3558a336f15d087fcebd865d060f24cebe5e7941b82faa832994ddd7d49fa
7
+ data.tar.gz: dc9d4206cfadebf124e19b669552f95b6e66c52081f18aa2d012eb973b5af6c134911a0549b06ec074e3cbc50bd0b65969215fdc38533ec96c2c90557517d64f
@@ -1,8 +1,12 @@
1
- hange Log
1
+ Change Log
2
2
  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
+ # 0.2.1 - 2016-09-01
7
+ ### changed
8
+ - fix bug in timeout parsing
9
+
6
10
  # 0.2.0 - 2016-09-01
7
11
  ### Added
8
12
  - check-storm-capacity script
@@ -11,5 +15,6 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
11
15
  ### Added
12
16
  - initial release
13
17
 
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
18
+ [0.2.1]: https://github.com/andyroyle/sensu-plugins-storm/compare/0.2.1...HEAD
19
+ [0.2.0]: https://github.com/andyroyle/sensu-plugins-storm/compare/0.2.0...0.2.1
20
+ [0.1.0]: https://github.com/andyroyle/sensu-plugins-storm/compare/0.1.0...0.2.0
@@ -21,17 +21,20 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
21
21
  option :host,
22
22
  short: '-h',
23
23
  long: '--host=VALUE',
24
- description: 'Cluster host'
24
+ description: 'Cluster host',
25
+ required: true
25
26
 
26
27
  option :user,
27
28
  short: '-u',
28
29
  long: '--username=VALUE',
29
- description: 'username'
30
+ description: 'username',
31
+ required: true
30
32
 
31
33
  option :pass,
32
34
  short: '-p',
33
35
  long: '--password=VALUE',
34
- description: 'password'
36
+ description: 'password',
37
+ required: true
35
38
 
36
39
  option :ssl,
37
40
  description: 'use HTTPS (default false)',
@@ -40,17 +43,22 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
40
43
  option :crit,
41
44
  short: '-c',
42
45
  long: '--critical=VALUE',
43
- description: 'Critical threshold'
46
+ description: 'Critical threshold',
47
+ required: true,
48
+ proc: proc { |l| l.to_f }
44
49
 
45
50
  option :warn,
46
51
  short: '-w',
47
52
  long: '--warn=VALUE',
48
- description: 'Warn threshold'
53
+ description: 'Warn threshold',
54
+ required: true,
55
+ proc: proc { |l| l.to_f }
49
56
 
50
57
  option :timeout,
51
58
  short: '-t',
52
59
  long: '--timeout=VALUE',
53
60
  description: 'Timeout in seconds',
61
+ proc: proc { |l| l.to_f },
54
62
  default: 5
55
63
 
56
64
  def request(path)
@@ -65,13 +73,6 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
65
73
  end
66
74
 
67
75
  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
76
  r = request('/stormui/api/v1/topology/summary')
76
77
 
77
78
  if r.code != 200
@@ -88,10 +89,10 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
88
89
  bolts = JSON.parse(t.to_str)['bolts']
89
90
  bolts.each do |bolt|
90
91
  capacity = bolt['capacity'].to_f
91
- if capacity > critical_usage
92
+ if capacity > config[:crit]
92
93
  critical "bolt #{bolt['boltId']} has capacity #{bolt['capacity']}"
93
- elsif capacity > warn_usage
94
- warn "bolt #{bolt['boltId']} has capacity #{bolt['capacity']}"
94
+ elsif capacity > config[:warn]
95
+ warning "bolt #{bolt['boltId']} has capacity #{bolt['capacity']}"
95
96
  end
96
97
  end
97
98
 
@@ -21,17 +21,20 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
21
21
  option :host,
22
22
  short: '-h',
23
23
  long: '--host=VALUE',
24
- description: 'Cluster host'
24
+ description: 'Cluster host',
25
+ required: true
25
26
 
26
27
  option :user,
27
28
  short: '-u',
28
29
  long: '--username=VALUE',
29
- description: 'username'
30
+ description: 'username',
31
+ required: true
30
32
 
31
33
  option :pass,
32
34
  short: '-p',
33
35
  long: '--password=VALUE',
34
- description: 'password'
36
+ description: 'password',
37
+ required: true
35
38
 
36
39
  option :ssl,
37
40
  description: 'use HTTPS (default false)',
@@ -41,18 +44,21 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
41
44
  short: '-c',
42
45
  long: '--critical=VALUE',
43
46
  description: 'Critical threshold',
44
- default: '0'
47
+ default: 0,
48
+ proc: proc { |l| l.to_f }
45
49
 
46
50
  option :expect,
47
51
  short: '-e',
48
52
  long: '--expect=VALUE',
49
- description: 'Match exactly the nuber of topologies'
53
+ description: 'Match exactly the number of topologies',
54
+ proc: proc { |l| l.to_f }
50
55
 
51
56
  option :timeout,
52
57
  short: '-t',
53
58
  long: '--timeout=VALUE',
54
59
  description: 'Timeout in seconds',
55
- default: 5
60
+ default: 5,
61
+ proc: proc { |l| l.to_f }
56
62
 
57
63
  def request(path)
58
64
  protocol = config[:ssl] ? 'https' : 'http'
@@ -66,13 +72,6 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
66
72
  end
67
73
 
68
74
  def run
69
- critical_usage = config[:crit].to_f
70
- expect = config[:expect].to_f
71
-
72
- if [config[:host], config[:user], config[:pass]].any?(&:nil?)
73
- unknown 'Must specify host, user and password'
74
- end
75
-
76
75
  r = request('/stormui/api/v1/topology/summary')
77
76
 
78
77
  if r.code != 200
@@ -80,13 +79,13 @@ class CheckStormTopologies < Sensu::Plugin::Check::CLI
80
79
  else
81
80
  topologies = JSON.parse(r.to_str)['topologies'].count
82
81
 
83
- if expect > 0 && topologies == expect
82
+ if config[:expect] && topologies == config[:expect]
84
83
  ok "Topologies: #{topologies}"
85
- elsif expect > 0
84
+ elsif config[:expect]
86
85
  critical "Topologies: #{topologies}"
87
86
  end
88
87
 
89
- if topologies <= critical_usage
88
+ if topologies <= config[:crit]
90
89
  critical "Topologies: #{topologies}"
91
90
  else
92
91
  ok "Topologies: #{topologies}"
@@ -2,7 +2,7 @@ module SensuPluginsStorm
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Royle