Module: AwsCleaner::Sensu
- Defined in:
- lib/aws-cleaner.rb
Class Method Summary collapse
-
.in_sensu?(node_name, config) ⇒ Boolean
check if the node exists in Sensu.
-
.remove_from_sensu(node_name, config) ⇒ Object
call the Sensu API to remove the node.
Class Method Details
.in_sensu?(node_name, config) ⇒ Boolean
check if the node exists in Sensu
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# 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) ⇒ Object
call the Sensu API to remove the node
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# 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 |