bin/check-chef-node.rb in sensu-plugins-chef-2.0.1 vs bin/check-chef-node.rb in sensu-plugins-chef-3.0.0
- old
+ new
@@ -25,11 +25,11 @@
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
#
require 'sensu-plugin/check/cli'
-require 'chef/rest'
+require 'ridley'
class ChefNodeChecker < Sensu::Plugin::Check::CLI
option :node_name,
description: 'Check if this node name exists',
short: '-n NODE-NAME',
@@ -48,17 +48,22 @@
option :key,
description: 'Client\'s key',
short: '-K CLIENT-KEY',
long: '--keys CLIENT-KEY'
+ option :ignore_ssl_verification,
+ description: 'Ignore SSL certificate verification',
+ short: '-i',
+ long: '--ignore-ssl'
+
def connection
@connection ||= chef_api_connection
end
def run
- node = connection.get_rest("/nodes/#{config[:node_name]}")
- if node['ohai_time']
+ node = connection.node.find(config[:node_name])
+ if node['automatic']['ohai_time']
ok "Node #{config[:node_name]} found"
else
warning "Node #{config[:node_name]} does not contain 'ohai_time' attribute"
end
rescue => e
@@ -69,8 +74,12 @@
def chef_api_connection
chef_server_url = config[:chef_server_url]
client_name = config[:client_name]
signing_key_filename = config[:key]
- Chef::REST.new(chef_server_url, client_name, signing_key_filename)
+ ignore_ssl = config[:ignore_ssl_verification]
+ verify_ssl = ignore_ssl.nil?
+
+ Celluloid.boot
+ Ridley.new(server_url: chef_server_url, client_name: client_name, client_key: signing_key_filename, ssl: { verify: verify_ssl })
end
end