-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tokumx recipe, which about three people will use.
- Loading branch information
Showing
5 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
include_recipe 'datadog::dd-agent' | ||
|
||
# Monitor tokumx | ||
# | ||
# node.set['datadog']['tokumx']['instances'] = [ | ||
# { | ||
# 'host' => 'localhost', | ||
# 'port' => '27017' | ||
# } | ||
# ] | ||
|
||
datadog_monitor 'tokumx' do | ||
instances node['datadog']['tokumx']['instances'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
describe 'datadog::tokumx' do | ||
expected_yaml = <<-EOF | ||
init_config: | ||
instances: | ||
- server: mongodb://localhost:27017 | ||
tags: | ||
- 'env:test' | ||
EOF | ||
|
||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new(step_into: ['datadog_monitor']) do |node| | ||
node.automatic['languages'] = { 'python' => { 'version' => '2.7.2' } } | ||
node.set['datadog'] = { | ||
api_key: 'someapikey', | ||
tokumx: { | ||
instances: [ | ||
{ | ||
host: 'localhost', | ||
port: '27017', | ||
tags: ['env:test'] | ||
} | ||
] | ||
} | ||
} | ||
end.converge(described_recipe) | ||
end | ||
|
||
subject { chef_run } | ||
|
||
it_behaves_like 'datadog-agent' | ||
|
||
it { is_expected.to include_recipe('datadog::dd-agent') } | ||
|
||
it { is_expected.to add_datadog_monitor('tokumx') } | ||
|
||
it 'renders expected YAML config file' do | ||
expect(chef_run).to(render_file('/etc/dd-agent/conf.d/tokumx.yaml').with_content { |content| | ||
expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) | ||
}) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
instances: | ||
<% @instances.each do |i| -%> | ||
- server: mongodb://<%= i['host']%>:<%= i['port'] %> | ||
<% if i.key?('tags') -%> | ||
tags: | ||
<% i['tags'].each do |t| -%> | ||
- <%= t %> | ||
<% end -%> | ||
<% end -%> | ||
<% if i.key?('ssl') -%> | ||
ssl: <%= i['ssl'] %> | ||
ssl_ca_certs: <%= i['ssl_ca_certs'] %> | ||
ssl_cert_reqs: <%= i['ssl_cert_reqs'] %> | ||
ssl_certfile: <%= i['ssl_certfile'] %> | ||
ssl_keyfile: <%= i['ssl_keyfile'] %> | ||
<% end %> | ||
<% if i.key?('additional_metrics') -%> | ||
additional_metrics: | ||
<% i['additional_metrics'].each do |t| %> | ||
- <%= t %> | ||
<%end -%> | ||
<% end %> | ||
<% if i.key?('collections') -%> | ||
collections: | ||
<% i['collections'].each do |t| %> | ||
- <%= t %> | ||
<%end -%> | ||
<% end %> | ||
<% end -%> | ||
|
||
init_config: | ||
# No init_config details needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Encoding: utf-8 | ||
|
||
require 'spec_helper' | ||
|
||
AGENT_CONFIG = File.join(@agent_config_dir, 'conf.d/tokumx.yaml') | ||
|
||
describe service(@agent_service_name) do | ||
it { should be_running } | ||
end | ||
|
||
describe file(AGENT_CONFIG) do | ||
it { should be_a_file } | ||
|
||
it 'is valid yaml matching input values' do | ||
generated = YAML.load_file(AGENT_CONFIG) | ||
|
||
expected = { | ||
'instances' => [ | ||
{ | ||
'server' => 'mongodb://localhost:27017' | ||
} | ||
], | ||
'init_config' => nil | ||
} | ||
|
||
expect(generated.to_json).to be_json_eql expected.to_json | ||
end | ||
end |