Skip to content

Commit cc69348

Browse files
authored
[activemq_xml] adding integration (#521)
* [activemq_xml] adding integration [activemq_xml] fixing tests + flakes * [activemq_xml] fixing documentation * [activemq_xml][spec] improve readability * [spec] improve agent5 test switch readability * [activemq_xml] better docs
1 parent e28c270 commit cc69348

49 files changed

Lines changed: 431 additions & 187 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Class: datadog_agent::integrations::activemq_xml
2+
#
3+
# This class will install the necessary configuration for the activemq_xml integration
4+
#
5+
# Parameters:
6+
# $url
7+
# ActiveMQ administration web URL to gather the activemq_xml stats from.
8+
# $username
9+
# Username to use for authentication - optional
10+
# $password
11+
# Password to use for authentication - optional
12+
# $supress_errors
13+
# Supress connection errors if URL is expected to be offline at times (eg. standby host) - optional
14+
# $detailed_queues
15+
# List of queues to monitor, required if you have more than 300 queues you wish to track, otherwise optional.
16+
# $detailed_topics
17+
# List of topics to monitor, required if you have more than 300 topics you wish to track, otherwise optional.
18+
# $detailed_subscribers
19+
# List of subscribers to monitor, required if you have more than 300 subscribers you wish to track, otherwise optional.
20+
#
21+
# Sample Usage:
22+
#
23+
# class { 'datadog_agent::integrations::activemq_xml' :
24+
# url => 'http://localhost:8161',
25+
# username => 'datadog',
26+
# password => 'some_pass',
27+
# supress_errors => false,
28+
# detailed_queues => ['queue1', 'queue2', 'queue3'],
29+
# detailed_topics => ['topic1', 'topic2', 'topic3'],
30+
# detailed_subscribers => ['subscriber1', 'subscriber2', 'subscriber3'],
31+
# }
32+
#
33+
# Hiera Usage:
34+
#
35+
# datadog_agent::integrations::activemq_xml::instances:
36+
# - host: 'http://localhost:8161'
37+
# username: 'datadog'
38+
# password: 'some_pass'
39+
# supress_errors: false
40+
# detailed_queues: ['queue1', 'queue2', 'queue3'],
41+
# detailed_topics: ['topic1', 'topic2', 'topic3'],
42+
# detailed_subscribers: ['subscriber1', 'subscriber2', 'subscriber3'],
43+
#
44+
#
45+
class datadog_agent::integrations::activemq_xml(
46+
String $url = 'http://localhost:8161',
47+
Boolean $supress_errors = false,
48+
Optional[String] $username = undef,
49+
Optional[String] $password = undef,
50+
Optional[Array[String]] $detailed_queues = [],
51+
Optional[Array[String]] $detailed_topics = [],
52+
Optional[Array[String]] $detailed_subscribers = [],
53+
Optional[Array] $instances = undef,
54+
) inherits datadog_agent::params {
55+
include datadog_agent
56+
57+
$legacy_dst = "${datadog_agent::conf_dir}/activemq_xml.yaml"
58+
if !$::datadog_agent::agent5_enable {
59+
$dst = "${datadog_agent::conf6_dir}/activemq_xml.d/conf.yaml"
60+
file { $legacy_dst:
61+
ensure => 'absent'
62+
}
63+
} else {
64+
$dst = $legacy_dst
65+
}
66+
67+
if !$instances and $url {
68+
$_instances = [{
69+
'url' => $url,
70+
'username' => $username,
71+
'password' => $password,
72+
'supress_errors' => $supress_errors,
73+
'detailed_queues' => $detailed_queues,
74+
'detailed_topics' => $detailed_topics,
75+
'detailed_subscribers' => $detailed_subscribers,
76+
}]
77+
} elsif !$instances{
78+
$_instances = []
79+
} else {
80+
$_instances = $instances
81+
}
82+
83+
file { $dst:
84+
ensure => file,
85+
owner => $datadog_agent::params::dd_user,
86+
group => $datadog_agent::params::dd_group,
87+
mode => '0600',
88+
content => template('datadog_agent/agent-conf.d/activemq_xml.yaml.erb'),
89+
require => Package[$datadog_agent::params::package_name],
90+
notify => Service[$datadog_agent::params::service_name],
91+
}
92+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
require 'spec_helper'
2+
3+
describe 'datadog_agent::integrations::activemq_xml' do
4+
context 'supported agents - v5 and v6' do
5+
agents = { '5' => true, '6' => false }
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
8+
let(:facts) {{
9+
operatingsystem: 'Ubuntu',
10+
}}
11+
if is_agent5
12+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
13+
else
14+
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
15+
end
16+
let(:dd_user) { 'dd-agent' }
17+
let(:dd_group) { 'root' }
18+
let(:dd_package) { 'datadog-agent' }
19+
let(:dd_service) { 'datadog-agent' }
20+
if is_agent5
21+
let(:conf_file) { "#{conf_dir}/activemq_xml.yaml" }
22+
else
23+
let(:conf_file) { "#{conf_dir}/activemq_xml.d/conf.yaml" }
24+
end
25+
26+
context 'with default parameters' do
27+
it { should compile }
28+
end
29+
30+
context 'with password set' do
31+
let(:params) {{
32+
username: 'foo',
33+
password: 'abc123',
34+
}}
35+
36+
it { should compile.with_all_deps }
37+
it { should contain_file(conf_file).with(
38+
owner: dd_user,
39+
group: dd_group,
40+
mode: '0600',
41+
)}
42+
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
43+
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
44+
it { should contain_file(conf_file).with_content(/username: foo/) }
45+
it { should contain_file(conf_file).with_content(/password: abc123/) }
46+
47+
context 'with default parameters' do
48+
it {
49+
should contain_file(conf_file)
50+
.with_content(%r{http://localhost:8161})
51+
.with_content(%r{supress_errors: false})
52+
.without_content(%r{detailed_queues:})
53+
.without_content(%r{detailed_topics:})
54+
.without_content(%r{detailed_subscribers:})
55+
}
56+
end
57+
58+
context 'with extra detailed parameters' do
59+
let(:params) {{
60+
supress_errors: true,
61+
detailed_queues: %w(queue1 queue2),
62+
detailed_topics: %w(topic1 topic2),
63+
detailed_subscribers: %w(subscriber1 subscriber2),
64+
}}
65+
it {
66+
should contain_file(conf_file)
67+
.with_content(%r{http://localhost:8161})
68+
.with_content(%r{supress_errors: true})
69+
.with_content(%r{detailed_queues:.*\s+- queue1\s+- queue2})
70+
.with_content(%r{detailed_topics:.*\s+- topic1\s+- topic2})
71+
.with_content(%r{detailed_subscribers:.*\s+- subscriber1\s+- subscriber2})
72+
}
73+
end
74+
75+
context 'with instances set' do
76+
let(:params) {{
77+
instances: [
78+
{
79+
'url' => 'http://localhost:8161',
80+
'username' => 'joe',
81+
'password' => 'hunter1',
82+
'detailed_queues' => %w(queue1 queue2),
83+
'detailed_topics' => %w(topic1 topic2),
84+
'detailed_subscribers' => %w(subscriber1 subscriber2),
85+
},
86+
{
87+
'url' => 'http://remotehost:8162',
88+
'username' => 'moe',
89+
'password' => 'hunter2',
90+
'detailed_queues' => %w(queue3 queue4),
91+
'detailed_topics' => %w(topic3 topic4),
92+
'detailed_subscribers' => %w(subscriber3 subscriber4),
93+
},
94+
],
95+
}}
96+
it {
97+
should contain_file(conf_file)
98+
.with_content(%r{url: http://localhost:8161})
99+
.without_content(%r{supress_errors:})
100+
.with_content(%r{username: joe})
101+
.with_content(%r{password: hunter1})
102+
.with_content(%r{detailed_queues:.*\s+- queue1\s+- queue2})
103+
.with_content(%r{detailed_topics:.*\s+- topic1\s+- topic2})
104+
.with_content(%r{detailed_subscribers:.*\s+- subscriber1\s+- subscriber2})
105+
.with_content(%r{url: http://remotehost:8162})
106+
.without_content(%r{supress_errors:})
107+
.with_content(%r{username: moe})
108+
.with_content(%r{password: hunter2})
109+
.with_content(%r{detailed_queues:.*\s+- queue3\s+- queue4})
110+
.with_content(%r{detailed_topics:.*\s+- topic3\s+- topic4})
111+
.with_content(%r{detailed_subscribers:.*\s+- subscriber3\s+- subscriber4})
112+
}
113+
end
114+
end
115+
end
116+
end
117+
end

spec/classes/datadog_agent_integrations_apache_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
describe 'datadog_agent::integrations::apache' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |_, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
8-
if enabled
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
8+
if is_agent5
99
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1010
else
1111
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -14,8 +14,8 @@
1414
let(:dd_group) { 'root' }
1515
let(:dd_package) { 'datadog-agent' }
1616
let(:dd_service) { 'datadog-agent' }
17-
let(:agent5_enable) { enabled }
18-
if enabled
17+
let(:agent5_enable) { is_agent5 }
18+
if is_agent5
1919
let(:conf_file) { "#{conf_dir}/apache.yaml" }
2020
else
2121
let(:conf_file) { "#{conf_dir}/apache.d/conf.yaml" }

spec/classes/datadog_agent_integrations_cacti_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
describe 'datadog_agent::integrations::cacti' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |agent, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
6+
agents.each do |agent, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
88
let(:facts) {{
99
operatingsystem: 'Ubuntu',
1010
}}
11-
if enabled
11+
if is_agent5
1212
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1313
else
1414
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -17,8 +17,8 @@
1717
let(:dd_group) { 'root' }
1818
let(:dd_package) { 'datadog-agent' }
1919
let(:dd_service) { 'datadog-agent' }
20-
let(:agent5_enable) { enabled }
21-
if enabled
20+
let(:agent5_enable) { is_agent5 }
21+
if is_agent5
2222
let(:conf_file) { "#{conf_dir}/cacti.yaml" }
2323
else
2424
let(:conf_file) { "#{conf_dir}/cacti.d/conf.yaml" }

spec/classes/datadog_agent_integrations_cassandra_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
describe 'datadog_agent::integrations::cassandra' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |_, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
88
let(:facts) {{
99
operatingsystem: 'Ubuntu',
1010
}}
11-
if enabled
11+
if is_agent5
1212
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1313
else
1414
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -17,7 +17,7 @@
1717
let(:dd_group) { 'root' }
1818
let(:dd_package) { 'datadog-agent' }
1919
let(:dd_service) { 'datadog-agent' }
20-
if enabled
20+
if is_agent5
2121
let(:conf_file) { "#{conf_dir}/cassandra.yaml" }
2222
else
2323
let(:conf_file) { "#{conf_dir}/cassandra.d/conf.yaml" }

spec/classes/datadog_agent_integrations_ceph_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
describe 'datadog_agent::integrations::ceph' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |_, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
88
let(:facts) {{
99
operatingsystem: 'Ubuntu',
1010
}}
11-
if enabled
11+
if is_agent5
1212
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1313
else
1414
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -17,7 +17,7 @@
1717
let(:dd_group) { 'root' }
1818
let(:dd_package) { 'datadog-agent' }
1919
let(:dd_service) { 'datadog-agent' }
20-
if enabled
20+
if is_agent5
2121
let(:conf_file) { "#{conf_dir}/ceph.yaml" }
2222
else
2323
let(:conf_file) { "#{conf_dir}/ceph.d/conf.yaml" }

spec/classes/datadog_agent_integrations_consul_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
describe 'datadog_agent::integrations::consul' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |_, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
88
let(:facts) {{
99
operatingsystem: 'Ubuntu',
1010
}}
11-
if enabled
11+
if is_agent5
1212
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1313
else
1414
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -17,7 +17,7 @@
1717
let(:dd_group) { 'root' }
1818
let(:dd_package) { 'datadog-agent' }
1919
let(:dd_service) { 'datadog-agent' }
20-
if enabled
20+
if is_agent5
2121
let(:conf_file) { "#{conf_dir}/consul.yaml" }
2222
else
2323
let(:conf_file) { "#{conf_dir}/consul.d/conf.yaml" }

spec/classes/datadog_agent_integrations_directory_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
describe 'datadog_agent::integrations::directory' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |_, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
88
let(:facts) {{
99
operatingsystem: 'Ubuntu',
1010
}}
11-
if enabled
11+
if is_agent5
1212
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1313
else
1414
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -17,7 +17,7 @@
1717
let(:dd_group) { 'root' }
1818
let(:dd_package) { 'datadog-agent' }
1919
let(:dd_service) { 'datadog-agent' }
20-
if enabled
20+
if is_agent5
2121
let(:conf_file) { "#{conf_dir}/directory.yaml" }
2222
else
2323
let(:conf_file) { "#{conf_dir}/directory.d/conf.yaml" }

spec/classes/datadog_agent_integrations_disk_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
describe 'datadog_agent::integrations::disk' do
44
context 'supported agents - v5 and v6' do
55
agents = { '5' => true, '6' => false }
6-
agents.each do |_, enabled|
7-
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
6+
agents.each do |_, is_agent5|
7+
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
88
let(:facts) {{
99
operatingsystem: 'Ubuntu',
1010
}}
11-
if enabled
11+
if is_agent5
1212
let(:conf_dir) { '/etc/dd-agent/conf.d' }
1313
else
1414
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
@@ -17,7 +17,7 @@
1717
let(:dd_group) { 'root' }
1818
let(:dd_package) { 'datadog-agent' }
1919
let(:dd_service) { 'datadog-agent' }
20-
if enabled
20+
if is_agent5
2121
let(:conf_file) { "#{conf_dir}/disk.yaml" }
2222
else
2323
let(:conf_file) { "#{conf_dir}/disk.d/conf.yaml" }

0 commit comments

Comments
 (0)