Add Recipe for disk integration
Fixes
ADD
recipes/disk.rb
+#
+# 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' => true,
+# 'excluded_filesystems' => [
+# 'tmpfs'
+# ],
+# 'excluded_disks' => [
+# '/dev/sda1',
+# '/dev/sda2'
+# ],
+# 'excluded_disk_re' => '/dev/sde.*',
+# 'tag_by_filesystem' => false,
+# 'excluded_mountpoint_re' => '/mnt/somebody-elses-problem.*',
+# 'all_partitions' => false
+# }
+# ]
+
+datadog_monitor 'disk' do
+ instances node['datadog']['disk']['instances']
+ init_config nil
+end

ADD
spec/integrations/disk_spec.rb
+describe 'datadog::disk' do
+ expected_yaml = <<-EOF
+ init_config: {}
+
+ instances:
+ - use_mount: true
+ excluded_filesystems:
+ - tmpfs
+ excluded_disks:
+ - /dev/sda1
+ - /dev/sda2
+ excluded_disk_re: '/dev/sde.*'
+ tag_by_filesystem: false
+ excluded_mountpoint_re: '/mnt/somebody-elses-problem.*'
+ all_partitions: false
+ 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: true,
+ excluded_filesystems: ['tmpfs'],
+ excluded_disks: ['/dev/sda1', '/dev/sda2'],
+ excluded_disk_re: '/dev/sde.*',
+ tag_by_filesystem: false,
+ excluded_mountpoint_re: '/mnt/somebody-elses-problem.*',
+ all_partitions: false
+ }
+ ]
+ }
+ }
+ 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

ADD
templates/default/disk.yaml.erb
+# Generated by Chef, local modifications will be overwritten
+
+<%= JSON.parse(({ 'instances' => @instances, 'init_config' => @init_config }).to_json).to_yaml %>

Add Recipe for disk integration (#430)

Fixes #429