Sha256: 65fa9ddf5ebae4636b647b2bb9060711b397e8766186c3f46ae997f8d2b55533
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
# encoding: UTF-8 module DumblogChef class Handler < Chef::Handler attr_reader :group def initialize(group='/chef') @group = group end def report if run_status.failed? time = Time.now.utc instance_id = `wget -qO- http://169.254.169.254/latest/meta-data/instance-id` stream = "#{time.strftime("%Y/%m/%d")}/#{instance_id}" message = {} message[:subject] = "chef-client Run Failed" message[:time] = time.iso8601 message[:node] = "Chef run failed on #{node.name}" message[:instance_id] = instance_id message[:exception] = run_status.formatted_exception message[:backtrace] = Array(backtrace).join('\n') file = Tempfile.new('dumblog-chef') begin file.write message.to_json file.flush `for i in {1..5}; do dumblog -group #{group} -stream #{stream} $(cat #{file.path}) && break || sleep 15; done` ensure file.close file.unlink end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dumblog-chef-0.1.0 | lib/dumblog-chef/handler.rb |