Added the option to enable USM
MODIFY
README.md
README.md
@@ -311,6 +311,8 @@ The [system-probe recipe][17] is automatically included by default. It writes th
To enable [Network Performance Monitoring][7] (NPM) in `system-probe.yaml`, set `node['datadog']['system_probe']['network_enabled']` to true.
+To enable [Universal Service Monitoring][7] (NPM) in `system-probe.yaml`, set `node['datadog']['system_probe']['service_monitoring_enabled']` to true.
+
**Note for Windows users**: NPM is supported on Windows with Agent v6.27+ and v7.27+. It ships as an optional component that is only installed if `node['datadog']['system_probe']['network_enabled']` is set to true when the Agent is installed or upgraded. Because of this, existing installations might need to do an uninstall and reinstall of the Agent once to install the NPM component, unless the Agent is upgraded at the same time.
## Resources

MODIFY
attributes/default.rb
attributes/default.rb
@@ -389,6 +389,7 @@ default['datadog']['system_probe']['enable_conntrack'] = false
# When this is set to nil (default), `network_config` won't be rendered in system-probe.yaml,
# making the Agent use the default setting for this value.
default['datadog']['system_probe']['network_enabled'] = nil
+default['datadog']['system_probe']['service_monitoring_enabled'] = nil
# Logs functionality settings (Agent 6/7 only)
# Set `enable_logs_agent` to:

MODIFY
recipes/system-probe.rb
recipes/system-probe.rb
@@ -24,7 +24,7 @@ cws_enabled = node['datadog']['security_agent']['cws']['enabled']
sysprobe_enabled = if is_windows
node['datadog']['system_probe']['network_enabled']
else
- node['datadog']['system_probe']['enabled'] || node['datadog']['system_probe']['network_enabled'] || cws_enabled
+ node['datadog']['system_probe']['enabled'] || node['datadog']['system_probe']['network_enabled'] || node['datadog']['system_probe']['service_monitoring_enabled'] || cws_enabled
end
sysprobe_agent_start = sysprobe_enabled && node['datadog']['agent_start'] && node['datadog']['agent_enable'] ? :start : :stop

MODIFY
spec/system-probe_spec.rb
spec/system-probe_spec.rb
@@ -46,6 +46,55 @@ describe 'datadog::system-probe' do
end
end
+ context 'with service_monitoring_enabled set to true' do
+ cached(:solo) do
+ ChefSpec::SoloRunner.new(
+ platform: 'ubuntu',
+ version: '16.04'
+ ) do |node|
+ node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml`
+ node.normal['datadog'] = {
+ 'api_key' => 'somethingnotnil',
+ 'agent_major_version' => 6,
+ 'system_probe' => {
+ 'debug_port' => 123,
+ 'bpf_debug' => true,
+ 'sysprobe_socket' => '/test/ing.sock',
+ 'service_monitoring_enabled' => true,
+ }
+ }
+ end
+ end
+
+ cached(:chef_run) do
+ solo.converge(described_recipe) do
+ solo.resource_collection.insert(
+ Chef::Resource::Service.new('datadog-agent', solo.run_context))
+ end
+ end
+
+ it 'is created with enabled service_monitoring_enabled' do
+ expect(chef_run).to create_template('/etc/datadog-agent/system-probe.yaml')
+ end
+
+ it 'contains expected YAML configuration' do
+ expected_yaml = <<-EOF
+ service_monitoring_config:
+ enabled: true
+ system_probe_config:
+ bpf_debug: true
+ debug_port: 123
+ enable_conntrack: false
+ enabled: false
+ sysprobe_socket: "/test/ing.sock"
+ EOF
+
+ expect(chef_run).to(render_file('/etc/datadog-agent/system-probe.yaml').with_content { |content|
+ expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
+ })
+ end
+ end
+
context 'with network_enabled set to true' do
cached(:solo) do
ChefSpec::SoloRunner.new(

MODIFY
templates/default/system_probe.yaml.erb
templates/default/system_probe.yaml.erb
@@ -23,6 +23,11 @@ if !node['datadog']['system_probe']['network_enabled'].nil?
'enabled': node['datadog']['system_probe']['network_enabled'],
}
end
+if !node['datadog']['system_probe']['service_monitoring_enabled'].nil?
+ system_probe_config['service_monitoring_config'] = {
+ 'enabled': node['datadog']['system_probe']['service_monitoring_enabled'],
+ }
+end
-%>
# Generated by Chef, local modifications will be overwritten

Added the option to enable USM (#876)