Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed pluralize for this case.

  • Loading branch information...
commit 074186396210cfd1276dd41a3a9ea7a3deb91a89 1 parent 62ac063
@alq666 alq666 authored
Showing with 11 additions and 7 deletions.
  1. +11 −7 lib/puppet/reports/datadog_reports.rb
View
18 lib/puppet/reports/datadog_reports.rb
@@ -4,30 +4,33 @@
begin
require 'dogapi'
rescue LoadError => e
- Puppet.info "You need the `dogapi` gem to use the DataDog report"
+ Puppet.info "You need the `dogapi` gem to use the Datadog report"
end
Puppet::Reports.register_report(:datadog_reports) do
configfile = "/etc/dd-agent/datadog.yaml"
- raise(Puppet::ParseError, "DataDog report config file #{configfile} not readable") unless File.exist?(configfile)
+ raise(Puppet::ParseError, "Datadog report config file #{configfile} not readable") unless File.exist?(configfile)
config = YAML.load_file(configfile)
API_KEY = config[:datadog_api_key]
desc <<-DESC
- Send notification of metrics to DataDog
+ Send notification of metrics to Datadog
DESC
def pluralize(number, noun)
begin
- case number
- when 0..1
+ if number == 0 then
+ "no #{noun}"
+ elsif number < 1 then
"less than 1 #{noun}"
+ elsif number == 1 then
+ "1 #{noun}"
else
"#{number.round} #{noun}s"
end
rescue
- "#{number} #{noun}s"
+ "#{number} #{noun}(s)"
end
end
@@ -92,7 +95,7 @@ def process
event_data << "@@@\n"
end
- Puppet.debug "Sending metrics for #{@msg_host} to DataDog"
+ Puppet.debug "Sending metrics for #{@msg_host} to Datadog"
@dog = Dogapi::Client.new(API_KEY)
self.metrics.each { |metric,data|
data.values.each { |val|
@@ -102,6 +105,7 @@ def process
}
}
+ Puppet.debug "Sending events for #{@msg_host} to Datadog"
@dog.emit_event(Dogapi::Event.new(event_data,
:msg_title => event_title,
:event_type => 'config_management.run',
Please sign in to comment.
Something went wrong with that request. Please try again.