Class: Undev::Handler
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- Undev::Handler
- Defined in:
- lib/chef/undev/handler/reporter.rb
Instance Method Summary collapse
Instance Method Details
#format_exception ⇒ Object
23 24 25 26 |
# File 'lib/chef/undev/handler/reporter.rb', line 23 def format_exception return nil unless exception "Chef-run failed [#{Time.now.strftime('%D %I:%M')}]\n #{exception.} " end |
#report ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/chef/undev/handler/reporter.rb', line 4 def report begin data = report_data url = "/undevapi" rest_client = Chef::REST.new(Chef::Config[:chef_server_url]) rest_client.post(url, data) rescue Chef::FileCache.store("failed-reporting-data.json", Chef::JSONCompat.to_json_pretty(data), 0640) Chef::Log.debug("Failed to post reporting data to server, saving to #{Chef::FileCache.load("failed-reporting-data.json", false)}") end end |
#report_data ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/chef/undev/handler/reporter.rb', line 28 def report_data data = {} data[:node] = node.fqdn data[:status] = riemann_status data[:run_list] = @run_status.node.run_list.to_json data[:start_time] = start_time.to_s data[:end_time] = end_time.to_s data[:message] = format_exception data[:tags] = node[:server_info_ng][:tags] if node[:server_info_ng] data end |
#riemann_status ⇒ Object
18 19 20 21 |
# File 'lib/chef/undev/handler/reporter.rb', line 18 def riemann_status return 'ok' unless exception 'critical' end |