-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa8d799
commit 8d67a3e
Showing
3 changed files
with
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
include_recipe 'datadog::dd-agent' | ||
|
||
# Build a data structure with configuration. | ||
# @see https://github.com/DataDog/dd-agent/blob/master/conf.d/php_fpm.yaml.example PHP-FPM Example | ||
# @example | ||
# node.override['datadog']['php_fpm']['instances'] = [ | ||
# { | ||
# 'status_url' => 'http://localhost/status', | ||
# 'ping_url' => 'http://localhost/ping', | ||
# 'ping_reply' => 'pong', | ||
# 'user' => 'bits', | ||
# 'password' => 'D4T4D0G', | ||
# 'tags' => ['prod'] | ||
# } | ||
# ] | ||
datadog_monitor 'php_fpm' do | ||
instances node['datadog']['php_fpm']['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,67 @@ | ||
describe 'datadog::php_fpm' do | ||
expected_yaml = <<-EOF | ||
init_config: | ||
instances: | ||
- status_url: http://localhost/status | ||
user: user | ||
password: mypassword | ||
tags: | ||
- optional_tag1 | ||
- optional_tag2 | ||
- ping_url: http://localhost/ping | ||
ping_reply: pong | ||
user: user | ||
password: mypassword | ||
tags: | ||
- optional_tag1 | ||
- optional_tag2 | ||
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', | ||
'php_fpm' => { | ||
'instances' => [ | ||
{ | ||
'password' => 'mypassword', | ||
'status_url' => 'http://localhost/status', | ||
'user' => 'user', | ||
'tags' => [ | ||
'optional_tag1', | ||
'optional_tag2' | ||
] | ||
}, | ||
{ | ||
'password' => 'mypassword', | ||
'ping_url' => 'http://localhost/ping', | ||
'ping_reply' => 'pong', | ||
'user' => 'user', | ||
'tags' => [ | ||
'optional_tag1', | ||
'optional_tag2' | ||
] | ||
} | ||
] | ||
} | ||
} | ||
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('php_fpm') } | ||
|
||
it 'renders expected YAML config file' do | ||
expect(chef_run).to render_file('/etc/dd-agent/conf.d/php_fpm.yaml').with_content { |content| | ||
expect(YAML.load(content).to_json).to be_json_eql(YAML.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,4 @@ | ||
<%= JSON.parse(({ 'instances' => @instances }).to_json).to_yaml %> | ||
|
||
init_config: | ||
# nothing to add here |