diff --git a/manifests/init.pp b/manifests/init.pp index 00b84e94..176767c1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -235,6 +235,7 @@ $sd_backend_host = '', $sd_backend_port = 0, $sd_template_dir = '', + $sd_jmx_enable = false, $consul_token = '', $conf_dir = $datadog_agent::params::conf_dir, $service_name = $datadog_agent::params::service_name, @@ -299,6 +300,7 @@ validate_string($sd_backend_host) validate_integer($sd_backend_port) validate_string($sd_template_dir) + validate_bool($sd_jmx_enable) validate_string($consul_token) if $hiera_tags { diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index 402c86e6..99728bae 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -199,6 +199,9 @@ it { should contain_file('/etc/dd-agent/datadog.conf').without( 'content' => /^consul_token:\n/, )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^# sd_jmx_enable: no\n/, + )} end end @@ -503,6 +506,7 @@ :sd_config_backend => 'etcd', :sd_backend_host => 'localhost', :sd_backend_port => '8080', + :sd_jmx_enable => true, }} it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^service_discovery_backend: docker\n/, @@ -516,6 +520,9 @@ it { should contain_file('/etc/dd-agent/datadog.conf').with( 'content' => /^sd_backend_port: 8080\n/, )} + it { should contain_file('/etc/dd-agent/datadog.conf').with( + 'content' => /^sd_jmx_enable: true\n/, + )} end end end diff --git a/templates/datadog.conf.erb b/templates/datadog.conf.erb index 00840f76..fa8455d4 100644 --- a/templates/datadog.conf.erb +++ b/templates/datadog.conf.erb @@ -387,6 +387,13 @@ sd_backend_port: <%= @sd_backend_port %> sd_template_dir: <%= @sd_template_dir %> <% end -%> +# Enable JMX checks for service discovery +<% if @sd_jmx_enable -%> +sd_jmx_enable: <%= @sd_jmx_enable %> +<% else -%> +# sd_jmx_enable: no +<% end -%> + # If you Consul store requires token authentication for service discovery, you can define that token here. <% if @consul_token.empty? -%> # consul_token: f45cbd0b-5022-samp-le00-4eaa7c1f40f1