Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions manifests/integrations/activemq_xml.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Class: datadog_agent::integrations::activemq_xml
#
# This class will install the necessary configuration for the activemq_xml integration
#
# Parameters:
# $url
# ActiveMQ administration web URL to gather the activemq_xml stats from.
# $username
# Username to use for authentication - optional
# $password
# Password to use for authentication - optional
# $supress_errors
# Supress connection errors if URL is expected to be offline at times (eg. standby host) - optional
# $detailed_queues
# List of queues to monitor, required if you have more than 300 queues you wish to track, otherwise optional.
# $detailed_topics
# List of topics to monitor, required if you have more than 300 topics you wish to track, otherwise optional.
# $detailed_subscribers
# List of subscribers to monitor, required if you have more than 300 subscribers you wish to track, otherwise optional.
#
# Sample Usage:
#
# class { 'datadog_agent::integrations::activemq_xml' :
# url => 'http://localhost:8161',
# username => 'datadog',
# password => 'some_pass',
# supress_errors => false,
# detailed_queues => ['queue1', 'queue2', 'queue3'],
# detailed_topics => ['topic1', 'topic2', 'topic3'],
# detailed_subscribers => ['subscriber1', 'subscriber2', 'subscriber3'],
# }
#
# Hiera Usage:
#
# datadog_agent::integrations::activemq_xml::instances:
# - host: 'http://localhost:8161'
# username: 'datadog'
# password: 'some_pass'
# supress_errors: false
# detailed_queues: ['queue1', 'queue2', 'queue3'],
# detailed_topics: ['topic1', 'topic2', 'topic3'],
# detailed_subscribers: ['subscriber1', 'subscriber2', 'subscriber3'],
#
#
class datadog_agent::integrations::activemq_xml(
String $url = 'http://localhost:8161',
Boolean $supress_errors = false,
Optional[String] $username = undef,
Optional[String] $password = undef,
Optional[Array[String]] $detailed_queues = [],
Optional[Array[String]] $detailed_topics = [],
Optional[Array[String]] $detailed_subscribers = [],
Optional[Array] $instances = undef,
) inherits datadog_agent::params {
include datadog_agent

$legacy_dst = "${datadog_agent::conf_dir}/activemq_xml.yaml"
if !$::datadog_agent::agent5_enable {
$dst = "${datadog_agent::conf6_dir}/activemq_xml.d/conf.yaml"
file { $legacy_dst:
ensure => 'absent'
}
} else {
$dst = $legacy_dst
}

if !$instances and $url {
$_instances = [{
'url' => $url,
'username' => $username,
'password' => $password,
'supress_errors' => $supress_errors,
'detailed_queues' => $detailed_queues,
'detailed_topics' => $detailed_topics,
'detailed_subscribers' => $detailed_subscribers,
}]
} elsif !$instances{
$_instances = []
} else {
$_instances = $instances
}

file { $dst:
ensure => file,
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
mode => '0600',
content => template('datadog_agent/agent-conf.d/activemq_xml.yaml.erb'),
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name],
}
}
117 changes: 117 additions & 0 deletions spec/classes/datadog_agent_integrations_activemq_xml_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
require 'spec_helper'

describe 'datadog_agent::integrations::activemq_xml' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
end
let(:dd_user) { 'dd-agent' }
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
if is_agent5
let(:conf_file) { "#{conf_dir}/activemq_xml.yaml" }
else
let(:conf_file) { "#{conf_dir}/activemq_xml.d/conf.yaml" }
end

context 'with default parameters' do
it { should compile }
end

context 'with password set' do
let(:params) {{
username: 'foo',
password: 'abc123',
}}

it { should compile.with_all_deps }
it { should contain_file(conf_file).with(
owner: dd_user,
group: dd_group,
mode: '0600',
)}
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
it { should contain_file(conf_file).with_content(/username: foo/) }
it { should contain_file(conf_file).with_content(/password: abc123/) }

context 'with default parameters' do
it {
should contain_file(conf_file)
.with_content(%r{http://localhost:8161})
.with_content(%r{supress_errors: false})
.without_content(%r{detailed_queues:})
.without_content(%r{detailed_topics:})
.without_content(%r{detailed_subscribers:})
}
end

context 'with extra detailed parameters' do
let(:params) {{
supress_errors: true,
detailed_queues: %w(queue1 queue2),
detailed_topics: %w(topic1 topic2),
detailed_subscribers: %w(subscriber1 subscriber2),
}}
it {
should contain_file(conf_file)
.with_content(%r{http://localhost:8161})
.with_content(%r{supress_errors: true})
.with_content(%r{detailed_queues:.*\s+- queue1\s+- queue2})
.with_content(%r{detailed_topics:.*\s+- topic1\s+- topic2})
.with_content(%r{detailed_subscribers:.*\s+- subscriber1\s+- subscriber2})
}
end

context 'with instances set' do
let(:params) {{
instances: [
{
'url' => 'http://localhost:8161',
'username' => 'joe',
'password' => 'hunter1',
'detailed_queues' => %w(queue1 queue2),
'detailed_topics' => %w(topic1 topic2),
'detailed_subscribers' => %w(subscriber1 subscriber2),
},
{
'url' => 'http://remotehost:8162',
'username' => 'moe',
'password' => 'hunter2',
'detailed_queues' => %w(queue3 queue4),
'detailed_topics' => %w(topic3 topic4),
'detailed_subscribers' => %w(subscriber3 subscriber4),
},
],
}}
it {
should contain_file(conf_file)
.with_content(%r{url: http://localhost:8161})
.without_content(%r{supress_errors:})
.with_content(%r{username: joe})
.with_content(%r{password: hunter1})
.with_content(%r{detailed_queues:.*\s+- queue1\s+- queue2})
.with_content(%r{detailed_topics:.*\s+- topic1\s+- topic2})
.with_content(%r{detailed_subscribers:.*\s+- subscriber1\s+- subscriber2})
.with_content(%r{url: http://remotehost:8162})
.without_content(%r{supress_errors:})
.with_content(%r{username: moe})
.with_content(%r{password: hunter2})
.with_content(%r{detailed_queues:.*\s+- queue3\s+- queue4})
.with_content(%r{detailed_topics:.*\s+- topic3\s+- topic4})
.with_content(%r{detailed_subscribers:.*\s+- subscriber3\s+- subscriber4})
}
end
end
end
end
end
10 changes: 5 additions & 5 deletions spec/classes/datadog_agent_integrations_apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe 'datadog_agent::integrations::apache' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
if enabled
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -14,8 +14,8 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
let(:agent5_enable) { enabled }
if enabled
let(:agent5_enable) { is_agent5 }
if is_agent5
let(:conf_file) { "#{conf_dir}/apache.yaml" }
else
let(:conf_file) { "#{conf_dir}/apache.d/conf.yaml" }
Expand Down
10 changes: 5 additions & 5 deletions spec/classes/datadog_agent_integrations_cacti_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'datadog_agent::integrations::cacti' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |agent, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
agents.each do |agent, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if enabled
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -17,8 +17,8 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
let(:agent5_enable) { enabled }
if enabled
let(:agent5_enable) { is_agent5 }
if is_agent5
let(:conf_file) { "#{conf_dir}/cacti.yaml" }
else
let(:conf_file) { "#{conf_dir}/cacti.d/conf.yaml" }
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_integrations_cassandra_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'datadog_agent::integrations::cassandra' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if enabled
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -17,7 +17,7 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
if enabled
if is_agent5
let(:conf_file) { "#{conf_dir}/cassandra.yaml" }
else
let(:conf_file) { "#{conf_dir}/cassandra.d/conf.yaml" }
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_integrations_ceph_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'datadog_agent::integrations::ceph' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if enabled
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -17,7 +17,7 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
if enabled
if is_agent5
let(:conf_file) { "#{conf_dir}/ceph.yaml" }
else
let(:conf_file) { "#{conf_dir}/ceph.d/conf.yaml" }
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_integrations_consul_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'datadog_agent::integrations::consul' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if enabled
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -17,7 +17,7 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
if enabled
if is_agent5
let(:conf_file) { "#{conf_dir}/consul.yaml" }
else
let(:conf_file) { "#{conf_dir}/consul.d/conf.yaml" }
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_integrations_directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'datadog_agent::integrations::directory' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if enabled
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -17,7 +17,7 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
if enabled
if is_agent5
let(:conf_file) { "#{conf_dir}/directory.yaml" }
else
let(:conf_file) { "#{conf_dir}/directory.d/conf.yaml" }
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_integrations_disk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'datadog_agent::integrations::disk' do
context 'supported agents - v5 and v6' do
agents = { '5' => true, '6' => false }
agents.each do |_, enabled|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{enabled}}" }
agents.each do |_, is_agent5|
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => #{is_agent5}}" }
let(:facts) {{
operatingsystem: 'Ubuntu',
}}
if enabled
if is_agent5
let(:conf_dir) { '/etc/dd-agent/conf.d' }
else
let(:conf_dir) { '/etc/datadog-agent/conf.d' }
Expand All @@ -17,7 +17,7 @@
let(:dd_group) { 'root' }
let(:dd_package) { 'datadog-agent' }
let(:dd_service) { 'datadog-agent' }
if enabled
if is_agent5
let(:conf_file) { "#{conf_dir}/disk.yaml" }
else
let(:conf_file) { "#{conf_dir}/disk.d/conf.yaml" }
Expand Down
Loading