Skip to content

Commit f504c54

Browse files
jameynelsontruthbk
authored andcommitted
First pass of adding network module (DataDog#346)
1 parent a96ca0f commit f504c54

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

manifests/integrations/network.pp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Class: datadog_agent::integrations::network
2+
#
3+
# This class will install the network integration
4+
#
5+
# Parameters:
6+
# $collect_connection_state
7+
# Enable TCP connection state counts
8+
#
9+
# Sample Usage:
10+
#
11+
# class { 'datadog_agent::integrations::network' :
12+
# collect_connection_state => false,
13+
# excluded_interfaces => [
14+
# 'lo0',
15+
# 'lo',
16+
# ],
17+
# excluded_interface_re => [
18+
# 'eth1.*'
19+
# ]
20+
# combine_connection_states => true
21+
# }
22+
#
23+
#
24+
class datadog_agent::integrations::network(
25+
$collect_connection_state = false,
26+
$excluded_interfaces = ['lo','lo0'],
27+
$excluded_interface_re = [],
28+
$combine_connection_states = true,
29+
) inherits datadog_agent::params {
30+
include ::datadog_agent
31+
32+
validate_array($excluded_interfaces)
33+
34+
file { "${datadog_agent::params::conf_dir}/network.yaml":
35+
ensure => file,
36+
owner => $datadog_agent::params::dd_user,
37+
group => $datadog_agent::params::dd_group,
38+
mode => '0600',
39+
content => template('datadog_agent/agent-conf.d/network.yaml.erb'),
40+
require => Package[$datadog_agent::params::package_name],
41+
notify => Service[$datadog_agent::params::service_name],
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
require 'spec_helper'
2+
3+
describe 'datadog_agent::integrations::network' do
4+
let(:facts) {{
5+
operatingsystem: 'Ubuntu',
6+
}}
7+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
8+
let(:dd_user) { 'dd-agent' }
9+
let(:dd_group) { 'root' }
10+
let(:dd_package) { 'datadog-agent' }
11+
let(:dd_service) { 'datadog-agent' }
12+
let(:conf_file) { "#{conf_dir}/network.yaml" }
13+
14+
context 'with default parameters' do
15+
it { should compile }
16+
end
17+
18+
context 'with collect_connection_state set' do
19+
let(:params) {{
20+
collect_connection_state: true,
21+
}}
22+
23+
it { should compile.with_all_deps }
24+
it { should contain_file(conf_file).with(
25+
owner: dd_user,
26+
group: dd_group,
27+
mode: '0600',
28+
)}
29+
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
30+
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
31+
32+
it { should contain_file(conf_file).with_content(%r{collect_connection_state: true}) }
33+
it { should contain_file(conf_file).without_content(%r{tags: }) }
34+
35+
context 'with excluded_interfaces parameter array' do
36+
let(:params) {{
37+
excluded_interfaces: %w{ lo lo0 eth0 },
38+
}}
39+
it { should contain_file(conf_file).with_content(/excluded_interfaces:[^-]+- lo\s+- lo0\s+- eth0\s*?[^-]/m) }
40+
end
41+
42+
end
43+
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# #
2+
# MANAGED BY PUPPET #
3+
# #
4+
init_config:
5+
6+
instances:
7+
- collect_connection_state: <%= @collect_connection_state %>
8+
<% if !@excluded_interfaces.empty? -%>
9+
excluded_interfaces:
10+
<%- (@excluded_interfaces.each do |interface| -%>
11+
- <%= interface %>
12+
<% end ) -%>
13+
<% end -%>
14+
<% if !@excluded_interface_re.empty? -%>
15+
excluded_interface_re:
16+
<%- (@excluded_interfaces_re.each do |interface| -%>
17+
- <%= interface %>
18+
<% end ) -%>
19+
<% end -%>
20+
combine_connection_states: <%= @combine_connection_states %>

0 commit comments

Comments
 (0)