Class: Chef::Handler::Graylog::GelfEventHandler
- Inherits:
-
EventDispatch::Base
- Object
- EventDispatch::Base
- Chef::Handler::Graylog::GelfEventHandler
- Defined in:
- lib/chef/handler/graylog/gelf_event_handler.rb
Instance Method Summary collapse
-
#initialize(sender) ⇒ GelfEventHandler
constructor
A new instance of GelfEventHandler.
- #resource_updated(resource, action) ⇒ Object
- #run_completed(node) ⇒ Object
- #run_failed(exception) ⇒ Object
- #run_started(run_status) ⇒ Object
Constructor Details
#initialize(sender) ⇒ GelfEventHandler
Returns a new instance of GelfEventHandler.
11 12 13 14 |
# File 'lib/chef/handler/graylog/gelf_event_handler.rb', line 11 def initialize(sender) @sender = sender @run_status = nil end |
Instance Method Details
#resource_updated(resource, action) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/handler/graylog/gelf_event_handler.rb', line 50 def resource_updated(resource, action) = (resource.node, 'resource_updated') . = "Resource updated: #{resource.resource_name}" .add_field('resource_action', Array(resource.action).join(',')) .add_field('resource_identity', resource.identity) .add_field('resource_name', resource.resource_name) .add_field('resource_cookbook_name', resource.cookbook_name) .add_field('resource_cookbook_version', resource.cookbook_version.version) .add_field('resource_recipe_name', resource.recipe_name) .add_field('resource_declared_type', resource.declared_type) .add_field('resource_defined_at', resource.defined_at) .add_field('resource_duration', resource.elapsed_time) @sender.send_payload() rescue Object => e log_error(__method__.downcase, e) end |
#run_completed(node) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chef/handler/graylog/gelf_event_handler.rb', line 22 def run_completed(node) = (node, 'run_completed') . = "Chef run succeeded on node #{node.name}" add_common_run_status_fields() @sender.send_payload() rescue Object => e log_error(__method__.downcase, e) end |
#run_failed(exception) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chef/handler/graylog/gelf_event_handler.rb', line 34 def run_failed(exception) = (@run_status.node, 'run_failed') . = "Chef run failed on node #{@run_status.node.name}" add_common_run_status_fields() .add_field('error_message', exception.to_s) .add_field('error_type', exception.class) .add_field('error_backtrace', Array(@run_status.backtrace).join("\n")) @sender.send_payload() rescue Object => e log_error(__method__.downcase, e) end |
#run_started(run_status) ⇒ Object
16 17 18 19 20 |
# File 'lib/chef/handler/graylog/gelf_event_handler.rb', line 16 def run_started(run_status) @run_status = run_status rescue Object => e log_error(__method__.downcase, e) end |