module AwsCleaner::Sensu
Public Class Methods
in_sensu?(node_name, config)
click to toggle source
check if the node exists in Sensu
# File lib/aws-cleaner.rb, line 66 def self.in_sensu?(node_name, config) RestClient::Request.execute( url: "#{config[:sensu][:url]}/clients/#{node_name}", method: :get, timeout: 5, open_timeout: 5 ) rescue RestClient::ResourceNotFound return false rescue StandardError => e puts "Sensu request failed: #{e}" return false else return true end
remove_from_sensu(node_name, config)
click to toggle source
call the Sensu
API to remove the node
# File lib/aws-cleaner.rb, line 83 def self.remove_from_sensu(node_name, config) response = RestClient::Request.execute( url: "#{config[:sensu][:url]}/clients/#{node_name}", method: :delete, timeout: 5, open_timeout: 5 ) case response.code when 202 AwsCleaner::Notify.notify_chat('Removed ' + node_name + ' from Sensu', config) return true else AwsCleaner::Notify.notify_chat('Failed to remove ' + node_name + ' from Sensu', config) return false end end