Class: SensuCleaner
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- SensuCleaner
- Defined in:
- lib/chef-handler-sensu.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #all_checks ⇒ Object
-
#initialize(config = {}) ⇒ SensuCleaner
constructor
A new instance of SensuCleaner.
- #report ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ SensuCleaner
Returns a new instance of SensuCleaner.
29 30 31 |
# File 'lib/chef-handler-sensu.rb', line 29 def initialize(config = {}) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/chef-handler-sensu.rb', line 27 def config @config end |
Instance Method Details
#all_checks ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/chef-handler-sensu.rb', line 33 def all_checks run_context.resource_collection.all_resources.select do |res| res.resource_name == :sensu_check end.collect do |check| check = check.name end end |
#report ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/chef-handler-sensu.rb', line 41 def report if run_status.failed? then return end checks = all_checks Dir[::File.join(node[:sensu][:directory], 'conf.d', 'checks', '*')].reject do |file| checks.include?(::File.basename(file, '.json')) end.each do |file| Chef::Log.warn "No sensu_check resources found for '#{::File.basename(file, '.json')}', deleting!" FileUtils.rm(file) end end |