Permalink
Browse files

makeing things better

  • Loading branch information...
1 parent 2d264ac commit c5078dc3af0e59830b5ac4e344125141f59fed5b @robbyt robbyt committed Dec 20, 2011
Showing with 35 additions and 2 deletions.
  1. +35 −2 lib/puppet/reports/datadog_reports.rb
@@ -20,11 +20,37 @@
def process
@summary = self.summary
+ @msg_host = self.host
+
+ event_title = ''
+ alert_type = ''
+ event_priority = ''
if defined?(self.status)
+ # for puppet log format 2 and above
@status = self.status
+ if @status == 'failed'
+ event_title = "Puppet failed on #{@msg_host}"
+ alert_type = "error"
+ event_priority = "normal"
+ elsif @status == 'changed'
+ event_title = "Puppet changed resources on #{@msg_host}"
+ alert_type = "success"
+ event_priority = "low"
+ elsif @status == "unchanged"
+ event_title = "Puppet ran on, and left #{@msg_host} unchanged"
+ alert_type = "success"
+ event_priority = "low"
+ else
+ event_title = "Puppet ran on #{@msg_host}"
+ alert_type = "success"
+ event_priority = "low"
+ end
+
else
- @status = 'Upgrade your PuppetMaster to > 2.6.8'
+ # for puppet log format 1
+ event_title = "Puppet ran on #{@msg_host}"
+ event_priority = "low"
end
Puppet.debug "Sending metrics for #{@msg_host} to DataDog"
@@ -42,6 +68,13 @@ def process
self.logs.each do |log|
output << log
end
- @dog.emit_event(Dogapi::Event.new(output.join("\n"), :msg_title => "Puppet run on #{@msg_host} (status: #{@status})", :event_type => 'Puppet'))
+ @dog.emit_event(Dogapi::Event.new(event_data,
+ :msg_title => event_title,
+ :event_type => 'config_management.run',
+ :event_object => @msg_host,
+ :alert_type => alert_type,
+ :priority => event_priority,
+ :source_type_name => 'puppet'
+ ), :host => @msg_host)
end
end

0 comments on commit c5078dc

Please sign in to comment.