sensu-plugins-consul 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8d9c05c1f82ff1a29ed5ce3e040ee63ce264967
4
- data.tar.gz: 78fa769434add3aa795a0e3702d5f55ed818a0a2
3
+ metadata.gz: 7756d3660b34f273f747362826658fecdbc6dfab
4
+ data.tar.gz: c47c6af671557229f903a45c1aa3d3e30dfc2538
5
5
  SHA512:
6
- metadata.gz: f8d00d68c1dbe5413f458a78e124baaac682498c2df76ed6833559e5dde730202150b1e2b5e6c2d3ba3689df112efab4f288a4285fc8432015a5c5bbab574665
7
- data.tar.gz: f9966a4e39326c0e6b8a6f0d2b9505bd54f18e60cb85c2ede097b87163eefe1c7f0d12cb3bb38996176863a8ceb765aa1b51172617edebfdf5c6b09ebb081d6b
6
+ metadata.gz: dbbda6260ae94b48b547f9ac7e5147753433541e6b6822efc147afff31b691ad3fadd763f1174ddb218033d673f41b7b8a2ab9986fdabf0fa9935988f63409e2
7
+ data.tar.gz: 853551656ca6f4fd6cc37dc2a3f4bdcf5136df89d87a364c35252cbe88875727648b2133caf50d1a513938c6d660364acbb2b8bf4b2464e3c0c2f441c2c624d7
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [1.2.0] - 2017-01-26
9
+ ### Added
10
+ - `check-consul-service-health` and `check-service-consul` now accept a --tags filter (@wg-tsuereth)
11
+
12
+ ### Fixed
13
+ - check-service-consul should look for 'critical' instead of 'failing' (@mattcl)
14
+
8
15
  ## [1.1.0] - 2016-08-03
9
16
  ### Added
10
17
  - check-consul-service-health and check-service-consul now accept a --fail-if-not-found argument @wg-tsuereth
@@ -64,7 +71,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
64
71
  ### Added
65
72
  - initial release
66
73
 
67
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-consul/compare/1.1.0...HEAD
74
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-consul/compare/1.2.0...HEAD
75
+ [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-consul/compare/1.1.0...1.2.0
68
76
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-consul/compare/1.0.0...1.1.0
69
77
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-consul/compare/0.1.7...1.0.0
70
78
  [0.1.7]: https://github.com/sensu-plugins/sensu-plugins-consul/compare/0.0.7...0.1.7
@@ -48,8 +48,13 @@ class CheckConsulServiceHealth < Sensu::Plugin::Check::CLI
48
48
  long: '--service SERVICE',
49
49
  default: 'consul'
50
50
 
51
+ option :tags,
52
+ description: 'filter services by a comma-separated list of tags (requires --service)',
53
+ short: '-t TAGS',
54
+ long: '--tags TAGS'
55
+
51
56
  option :all,
52
- description: 'get all services',
57
+ description: 'get all services (not compatible with --tags)',
53
58
  short: '-a',
54
59
  long: '--all'
55
60
 
@@ -60,7 +65,16 @@ class CheckConsulServiceHealth < Sensu::Plugin::Check::CLI
60
65
 
61
66
  # Get the service checks for the given service
62
67
  def acquire_service_data
63
- if config[:all]
68
+ if config[:tags] && config[:service]
69
+ tags = config[:tags].split(',').to_set
70
+ services = []
71
+ Diplomat::Health.service(config[:service]).each do |s|
72
+ if s['Service']['Tags'].to_set.superset? tags
73
+ services.push(*s['Checks'])
74
+ end
75
+ end
76
+ return services
77
+ elsif config[:all]
64
78
  Diplomat::Health.state('any')
65
79
  else
66
80
  Diplomat::Health.checks(config[:service])
@@ -69,6 +83,10 @@ class CheckConsulServiceHealth < Sensu::Plugin::Check::CLI
69
83
 
70
84
  # Do work
71
85
  def run
86
+ if config[:tags] && config[:all]
87
+ critical 'Cannot specify --tags and --all simultaneously (Consul health/service/ versus health/state/).'
88
+ end
89
+
72
90
  Diplomat.configure do |dc|
73
91
  dc.url = config[:consul]
74
92
  end
@@ -97,6 +115,9 @@ class CheckConsulServiceHealth < Sensu::Plugin::Check::CLI
97
115
  msg = 'Could not find checks for any services'
98
116
  if config[:service]
99
117
  msg = "Could not find checks for service #{config[:service]}"
118
+ if config[:tags]
119
+ msg += " with tags #{config[:tags]}"
120
+ end
100
121
  end
101
122
  critical msg
102
123
  end
@@ -46,8 +46,13 @@ class ServiceStatus < Sensu::Plugin::Check::CLI
46
46
  long: '--service SERVICE',
47
47
  default: 'consul'
48
48
 
49
+ option :tags,
50
+ description: 'filter services by a comma-separated list of tags (requires --service)',
51
+ short: '-t TAGS',
52
+ long: '--tags TAGS'
53
+
49
54
  option :all,
50
- description: 'get all services in a non-passing status',
55
+ description: 'get all services in a non-passing status (not compatible with --tags)',
51
56
  short: '-a',
52
57
  long: '--all'
53
58
 
@@ -59,7 +64,16 @@ class ServiceStatus < Sensu::Plugin::Check::CLI
59
64
  # Get the check data for the service from consul
60
65
  #
61
66
  def acquire_service_data
62
- if config[:all]
67
+ if config[:tags] && config[:service]
68
+ tags = config[:tags].split(',').to_set
69
+ services = []
70
+ Diplomat::Health.service(config[:service]).each do |s|
71
+ if s['Service']['Tags'].to_set.superset? tags
72
+ services.push(*s['Checks'])
73
+ end
74
+ end
75
+ return services
76
+ elsif config[:all]
63
77
  Diplomat::Health.state('any')
64
78
  else
65
79
  Diplomat::Health.checks(config[:service])
@@ -73,6 +87,10 @@ class ServiceStatus < Sensu::Plugin::Check::CLI
73
87
  # Main function
74
88
  #
75
89
  def run
90
+ if config[:tags] && config[:all]
91
+ critical 'Cannot specify --tags and --all simultaneously (Consul health/service/ versus health/state/).'
92
+ end
93
+
76
94
  Diplomat.configure do |dc|
77
95
  dc.url = config[:consul]
78
96
  end
@@ -92,13 +110,16 @@ class ServiceStatus < Sensu::Plugin::Check::CLI
92
110
  'service' => d['ServiceName'],
93
111
  'service_id' => d['ServiceID'],
94
112
  'notes' => d['Notes']
95
- } if d['Status'] == 'failing'
113
+ } if d['Status'] == 'critical'
96
114
  end
97
115
 
98
116
  if failing.empty? && passing.empty?
99
117
  msg = 'Could not find checks for any services'
100
118
  if config[:service]
101
119
  msg = "Could not find checks for service #{config[:service]}"
120
+ if config[:tags]
121
+ msg += " with tags #{config[:tags]}"
122
+ end
102
123
  end
103
124
  if config[:fail_if_not_found]
104
125
  critical msg
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsConsul
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 1
4
+ MINOR = 2
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-consul
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-04 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.5.1
235
+ rubygems_version: 2.4.5
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Sensu plugins for Consul