-
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.
Fixed #429 - Add Recipe for disk integration
- Loading branch information
Showing
3 changed files
with
94 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,35 @@ | ||
# | ||
# Cookbook Name: datadog | ||
# Recipe: disk | ||
# | ||
# This recipe exists to apply (optional) configuration to the disk integration | ||
# This recipe does not need to be included to use the disk integration, | ||
# but it allows you to override some defaults that the disk integration | ||
# provides. | ||
# For more information on the integration itself, see: | ||
# https://docs.datadoghq.com/integrations/disk/ | ||
|
||
include_recipe 'datadog::dd-agent' | ||
|
||
# example configuration: | ||
# node['datadog']['disk']['instances'] = [ | ||
# { | ||
# 'use_mount' => 'yes', | ||
# 'excluded_filesystems' => [ | ||
# 'tmpfs' | ||
# ], | ||
# 'excluded_disks' => [ | ||
# '/dev/sda1', | ||
# '/dev/sda2' | ||
# ], | ||
# 'excluded_disk_re' => '/dev/sde.*', | ||
# 'tag_by_filesystem' => 'no', | ||
# 'excluded_mountpoint_re' => '/mnt/somebody-elses-problem.*', | ||
# 'all_partitions' => 'no' | ||
# } | ||
# ] | ||
|
||
datadog_monitor 'disk' do | ||
instances node['datadog']['disk']['instances'] | ||
init_config nil | ||
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,56 @@ | ||
describe 'datadog::disk' do | ||
expected_yaml = <<-EOF | ||
init_config: {} | ||
instances: | ||
- use_mount: 'yes' | ||
excluded_filesystems: | ||
- tmpfs | ||
excluded_disks: | ||
- /dev/sda1 | ||
- /dev/sda2 | ||
excluded_disk_re: '/dev/sde.*' | ||
tag_by_filesystem: 'no' | ||
excluded_mountpoint_re: '/mnt/somebody-elses-problem.*' | ||
all_partitions: 'no' | ||
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', | ||
disk: { | ||
instances: [ | ||
{ | ||
use_mount: 'yes', | ||
excluded_filesystems: ['tmpfs'], | ||
excluded_disks: ['/dev/sda1', '/dev/sda2'], | ||
excluded_disk_re: '/dev/sde.*', | ||
tag_by_filesystem: 'no', | ||
excluded_mountpoint_re: '/mnt/somebody-elses-problem.*', | ||
all_partitions: 'no' | ||
} | ||
] | ||
} | ||
} | ||
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('disk') } | ||
|
||
it 'renders expected YAML config file' do | ||
expect(chef_run).to render_file('/etc/dd-agent/conf.d/disk.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,3 @@ | ||
# Generated by Chef, local modifications will be overwritten | ||
|
||
<%= JSON.parse(({ 'instances' => @instances, 'init_config' => @init_config }).to_json).to_yaml %> |