Commit 4f5d1ef4 authored by Tristan Michelet's avatar Tristan Michelet

wip

parent 6c8e0a0a
# Creates the proper yaml file in /etc/dd-agent/checks.e/<checks/uri>
def whyrun_supported?
true
end
action :add do
Chef::Log.debug "Adding monitoring for #{new_resource.name}" # FIXME hardcoded links
template "/home/vagrant/dd-agent/checks.e/#{new_resource.name}/check.yaml" do
owner 'dd-agent'
mode 00600
local true
source "/home/vagrant/dd-agent/checks.e/#{new_resource.name}/check.yaml.erb"
variables(
:init_config => new_resource.init_config,
:instances => new_resource.instances
)
notifies :restart, 'service[datadog-agent]', :delayed
end
new_resource.updated_by_last_action(false)
end
action :remove do
if ::File.exist?("/home/vagrant/dd-agent/checks.e/#{new_resource.name}/check.yaml")
Chef::Log.debug "Removing #{new_resource.name} from /etc/dd-agent/checks.e/"
file "/home/vagrant/dd-agent/checks.e/#{new_resource.name}/check.yaml" do
action :delete
notifies :restart, 'service[datadog-agent]', :delayed
end
new_resource.updated_by_last_action(true)
end
end
......@@ -9,9 +9,13 @@ node['datadog']['checkse'].each do |name, config|
command "sudo service datadog-agent install #{name}"
end
execute "configure check #{name}" do
puts "sudo service datadog-agent configure #{name} '#{JSON.dump(config)}'"
command "echo \"sudo service datadog-agent configure #{name} '#{JSON.dump(config)}'\""
if not name.include? "/"
name = 'tmichelet/dd-' + name + '-check' # FIXME
end
datadog_check_monitor name do
init_config config['init_config']
instances config['instances']
end
end
# Configure a service via its yaml file
actions :add, :remove
default_action :add if defined?(default_action)
attribute :name, :kind_of => String, :name_attribute => true
# checks have 2 sections: init_config and instances
# we mimic these here, no validation is performed until the template
# is evaluated.
attribute :init_config, :kind_of => Hash, :required => false, :default => {}
attribute :instances, :kind_of => Array, :required => false, :default => []
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment