Skip to content

Commit

Permalink
adding jmx check for service discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
Alvin Huang committed Jan 7, 2017
1 parent 3ddb8b4 commit 0b7b3a7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions spec/classes/datadog_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/,
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions templates/datadog.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b7b3a7

Please sign in to comment.