Skip to content

Commit 83835cb

Browse files
alvin-huangtruthbk
authored andcommitted
adding jmx check for service discovery (#296)
1 parent 240b024 commit 83835cb

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@
235235
$sd_backend_host = '',
236236
$sd_backend_port = 0,
237237
$sd_template_dir = '',
238+
$sd_jmx_enable = false,
238239
$consul_token = '',
239240
$conf_dir = $datadog_agent::params::conf_dir,
240241
$service_name = $datadog_agent::params::service_name,
@@ -299,6 +300,7 @@
299300
validate_string($sd_backend_host)
300301
validate_integer($sd_backend_port)
301302
validate_string($sd_template_dir)
303+
validate_bool($sd_jmx_enable)
302304
validate_string($consul_token)
303305

304306
if $hiera_tags {

spec/classes/datadog_agent_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@
199199
it { should contain_file('/etc/dd-agent/datadog.conf').without(
200200
'content' => /^consul_token:\n/,
201201
)}
202+
it { should contain_file('/etc/dd-agent/datadog.conf').with(
203+
'content' => /^# sd_jmx_enable: no\n/,
204+
)}
202205
end
203206
end
204207

@@ -503,6 +506,7 @@
503506
:sd_config_backend => 'etcd',
504507
:sd_backend_host => 'localhost',
505508
:sd_backend_port => '8080',
509+
:sd_jmx_enable => true,
506510
}}
507511
it { should contain_file('/etc/dd-agent/datadog.conf').with(
508512
'content' => /^service_discovery_backend: docker\n/,
@@ -516,6 +520,9 @@
516520
it { should contain_file('/etc/dd-agent/datadog.conf').with(
517521
'content' => /^sd_backend_port: 8080\n/,
518522
)}
523+
it { should contain_file('/etc/dd-agent/datadog.conf').with(
524+
'content' => /^sd_jmx_enable: true\n/,
525+
)}
519526
end
520527
end
521528
end

templates/datadog.conf.erb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ sd_backend_port: <%= @sd_backend_port %>
387387
sd_template_dir: <%= @sd_template_dir %>
388388
<% end -%>
389389

390+
# Enable JMX checks for service discovery
391+
<% if @sd_jmx_enable -%>
392+
sd_jmx_enable: <%= @sd_jmx_enable %>
393+
<% else -%>
394+
# sd_jmx_enable: no
395+
<% end -%>
396+
390397
# If you Consul store requires token authentication for service discovery, you can define that token here.
391398
<% if @consul_token.empty? -%>
392399
# consul_token: f45cbd0b-5022-samp-le00-4eaa7c1f40f1

0 commit comments

Comments
 (0)