sensu-plugins-chef 3.0.2 → 4.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: b79f63eea985ea3025336cfba7c01d196f9bedb3
4
- data.tar.gz: 89a2740d2124ce4320c2dbf76739bfd80c619a38
3
+ metadata.gz: 921c03d9102e7ba6eb3330438b783613bbb020a1
4
+ data.tar.gz: 495db0afca92ab3a4fcd2c8b28afc244988f1fcf
5
5
  SHA512:
6
- metadata.gz: 5868f712c21270307502291d99480ca3f5f5cb21a971329567ed1b2ee997473c42579acce15a986d8fc2891ceca297cba040d57c4e5354dde59b85803c1ebbdd
7
- data.tar.gz: 3dc6552f7f56373e3b63cacc1679b3d699bd01854506cdfc1f9a2cd8b282322ff16bc7b78764299b71a31aee474aa098df893c7958a2a9c959b4a95dbb44ee27
6
+ metadata.gz: 9018eb2a96f6f7b6dc76679554ec97583cf6ce76c14f1af5b5e7cc990d22366f0af7e0ebc531b850180327196509458c3d9245a0e4c76a363bc5852c9d604e69
7
+ data.tar.gz: 40f41e8eb1701604131be65eee08cafe2da795d002a5b3d375b3104579041667b88136fddd8505817b2e8f9ad311e7529938bc3ea6d4e55be158486c38d4a01b
@@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [4.0.0] - 2017-08-14
8
+ ### Breaking Change
9
+ - check-chef-nodes.rb: added an option for a grace_period which allows exclusion of nodes until they have been online for a specified ammount of time. Defaulting to 300 seconds. (@majormoses)
10
+ - check-chef-nodes.rb: when chef has not initially run we can not determine the time that it has been up for nor when it last converged as ohai will not have this information yet. Rather than assuming this is a failure we treat nodes that have no ohai data as not being able to be evaluated. If you are looking for something to catch nodes that fail initial bootstrap I would suggest something along the lines of [aws-watcher](https://github.com/majormoses/aws-watcher) (@majormoses)
11
+
12
+
7
13
  ## [3.0.2] - 2017-05-28
8
14
  ## Fixed
9
15
  - updating runtime deps
@@ -78,7 +84,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
78
84
  ### Added
79
85
  - initial release
80
86
 
81
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-chef/compare/3.0.2...HEAD
87
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-chef/compare/4.0.0...HEAD
88
+ [4.0.0]: https://github.com/sensu-plugins/sensu-plugins-chef/compare/3.0.2...4.0.0
82
89
  [3.0.2]: https://github.com/sensu-plugins/sensu-plugins-chef/compare/3.0.2...3.0.1
83
90
  [3.0.1]: https://github.com/sensu-plugins/sensu-plugins-chef/compare/3.0.1...3.0.0
84
91
  [3.0.0]: https://github.com/sensu-plugins/sensu-plugins-chef/compare/3.0.0...2.0.1
@@ -73,10 +73,18 @@ class ChefNodesStatusChecker < Sensu::Plugin::Check::CLI
73
73
  long: '--exclude-nodes EXCLUDE-NODES',
74
74
  default: '^$'
75
75
 
76
+ option :grace_period,
77
+ description: 'The ammount of time before a node should be evaluated for failed convergence',
78
+ long: '--grace-period SECONDS',
79
+ default: (60 * 5), # default 5 minutes, which seems like a good but not great default
80
+ proc: proc(&:to_i)
81
+
76
82
  option :ignore_ssl_verification,
77
83
  description: 'Ignore SSL certificate verification',
78
84
  short: '-i',
79
- long: '--ignore-ssl'
85
+ long: '--ignore-ssl',
86
+ default: false,
87
+ boolean: true
80
88
 
81
89
  def connection
82
90
  @connection ||= chef_api_connection
@@ -85,21 +93,37 @@ class ChefNodesStatusChecker < Sensu::Plugin::Check::CLI
85
93
  def nodes_last_seen
86
94
  nodes = connection.node.all
87
95
  nodes.delete_if { |node| node.name =~ /#{config[:exclude_nodes]}/ }
88
- nodes.map do |node|
96
+
97
+ checked_nodes = []
98
+ nodes.each do |node|
89
99
  node.reload
90
- if node['automatic']['ohai_time']
91
- { node.name => (Time.now - Time.at(node['automatic']['ohai_time'])) > config[:critical_timespan].to_i }
92
- else
93
- { node.name => true }
100
+ # no uptime: node might have not finished convergence -> won't check
101
+ unless node['automatic']['uptime_seconds']
102
+ checked_nodes << { node['name'] => false }
103
+ next
104
+ end
105
+
106
+ # won't check if node's uptime is still within grace period
107
+ unless node['automatic']['uptime_seconds'] > config[:grace_period]
108
+ checked_nodes << { node['name'] => false }
109
+ next
94
110
  end
111
+
112
+ # compute elapsed time since last convergence
113
+ checked_nodes << if node['automatic']['ohai_time']
114
+ { node['name'] => (Time.now - Time.at(node['automatic']['ohai_time'])) > config[:critical_timespan].to_i }
115
+ else
116
+ { node['name'] => true }
117
+ end
95
118
  end
119
+ checked_nodes
96
120
  end
97
121
 
98
122
  def run
99
123
  if any_node_stuck?
100
- ok 'Chef Server API is ok, all nodes reporting'
101
- else
102
124
  critical "The following nodes cannot be provisioned: #{failed_nodes_names}"
125
+ else
126
+ ok 'Chef Server API is ok, all nodes reporting'
103
127
  end
104
128
  end
105
129
 
@@ -117,12 +141,27 @@ class ChefNodesStatusChecker < Sensu::Plugin::Check::CLI
117
141
  end
118
142
 
119
143
  def any_node_stuck?
144
+ stuck = []
120
145
  @nodes_last_seen ||= nodes_last_seen
121
- @nodes_last_seen.map(&:values).flatten.all? { |x| x == false }
146
+ @nodes_last_seen.flatten.each do |node|
147
+ node.each do |name, status|
148
+ stuck << name if status == true
149
+ end
150
+ end
151
+ if stuck.empty?
152
+ false
153
+ else
154
+ true
155
+ end
122
156
  end
123
157
 
124
158
  def failed_nodes_names
125
- all_failed_tuples = @nodes_last_seen.select { |node_set| node_set.values.first == true }
126
- all_failed_tuples.map(&:keys).flatten.join(', ')
159
+ failed_nodes = []
160
+ @nodes_last_seen.flatten.each do |node|
161
+ node.each do |name, status|
162
+ failed_nodes << name if status == true
163
+ end
164
+ end
165
+ failed_nodes
127
166
  end
128
167
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsChef
2
2
  module Version
3
- MAJOR = 3
3
+ MAJOR = 4
4
4
  MINOR = 0
5
- PATCH = 2
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 4.0.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: 2017-05-29 00:00:00.000000000 Z
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef