forked from DataDog/puppet-datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtcp_check.pp
More file actions
129 lines (125 loc) · 3.78 KB
/
tcp_check.pp
File metadata and controls
129 lines (125 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Class: datadog_agent::integrations::tcp_check
#
# This class will install the necessary config to hook the tcp_check in the agent
#
# Parameters:
# name
# (Required) - Name of the service.
# This will be included as a tag: instance:<name>.
#
# host
# (Required) - Host to be checked.
# This will be included as a tag: url:<host>:<port>.
#
# port
# (Required) - Port to be checked.
# This will be included as a tag: url:<host>:<port>.
#
# timeout
# (Optional) - Timeout for the check. Defaults to 10 seconds.
#
# threshold
# (Optional) - Used in conjunction with window. An alert will
# trigger if the check fails <threshold> times in <window> attempts.
#
# window
# (Optional) - Refer to ‘threshold’.
#
# collect_response_time
# (Optional) - Defaults to false. If this is not set to true, no
# response time metric will be collected. If it is set to true, the
# metric returned is network.tcp.response_time.
#
# skip_event
# The (optional) skip_event parameter will instruct the check to not
# create any event to avoid duplicates with a server side service check.
# This default to False.
#
# tags
# The (optional) tags to add to the check instance.
#
# Sample Usage:
#
# Add a class for each check instance:
#
# class { 'datadog_agent::integrations::tcp_check':
# name => 'localhost-ftp',
# host => 'ftp.example.com',
# port => '21',
# }
#
# class { 'datadog_agent::integrations::tcp_check':
# name => 'localhost-ssh',
# host => '127.0.0.1',
# port => '22',
# threshold => 1,
# window => 1,
# tags => ['production', 'ssh access'],
# }
#
# class { 'datadog_agent::integrations::tcp_check':
# name => 'localhost-web-response',
# host => '127.0.0.1',
# port => '80',
# timeout => '8',
# threshold => 1,
# window => 1,
# collect_response_time => 1,
# skip_event => 1,
# tags => ['production', 'webserver response time'],
# }
#
# Add multiple instances in one class declaration:
#
# class { 'datadog_agent::integrations::tcp_check':
# instances => [{
# 'name' => 'www.example.com-http',
# 'host' => 'www.example.com',
# 'port' => '80',
# },
# {
# 'name' => 'www.example.com-https',
# 'host' => 'www.example.com',
# 'port' => '443',
# }]
# }
class datadog_agent::integrations::tcp_check (
$name = undef,
$host = undef,
$port = undef,
$timeout = 10,
$threshold = undef,
$window = undef,
$collect_response_time = undef,
$skip_event = undef,
$tags = [],
$instances = undef,
) inherits datadog_agent::params {
include datadog_agent
if !$instances and $host {
$_instances = [{
'name' => $name,
'host' => $host,
'port' => $port,
'timeout' => $timeout,
'threshold' => $threshold,
'window' => $window,
'collect_response_time' => $collect_response_time,
'skip_event' => $skip_event,
'tags' => $tags,
}]
} elsif !$instances{
$_instances = []
} else {
$_instances = $instances
}
file { "${datadog_agent::params::conf_dir}/tcp_check.yaml":
ensure => file,
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
mode => '0600',
content => template('datadog_agent/agent-conf.d/tcp_check.yaml.erb'),
require => Package[$datadog_agent::params::package_name],
notify => Service[$datadog_agent::params::service_name]
}
}