Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiple instances in the http_check. #155

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions manifests/integrations/http_check.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,26 @@
$headers = [],
$tags = [],
$contact = [],
$instances = undef,
) inherits datadog_agent::params {

if $instances == undef {
$instances = [{
'url' => $url,
'username' => $username,
'password' => $password,
'timeout' => $timeout,
'threshold' => $threshold,
'window' => $window,
'include_content' => $include_content,
'collect_response_time' => $collect_repsonse_time,
'disable_ssl_verification' => $disable_ssl_verification,
'headers' => $headers,
'tags' => $tags,
'contact' => $contact,
}]
}

file { "${datadog_agent::params::conf_dir}/http_check.yaml":
ensure => file,
owner => $datadog_agent::params::dd_user,
Expand Down
49 changes: 25 additions & 24 deletions templates/agent-conf.d/http_check.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,52 +1,53 @@
init_config:

instances:
- name: <%= @name %>
url: <%= @url %>
<% if @timeout -%>
timeout: <%= @timeout %>
<%- (Array(@instances)).each do |instance| -%>
- name: <%= instance['name'] %>
url: <%= instance['url'] %>
<% if instance['timeout'] -%>
timeout: <%= instance['timeout'] %>
<% end -%>
<% if @username -%>
username: <%= @username %>
<% if instance['username'] -%>
username: <%= instance['username'] %>
<% end -%>
<% if @password -%>
password: <%= @password %>
<% if instance['password'] -%>
password: <%= instance['password'] %>
<% end -%>
<% if @threshold -%>
threshold: <%= @threshold %>
<% if instance['threshold'] -%>
threshold: <%= instance['threshold'] %>
<% end -%>
<% if @window -%>
window: <%= @window %>
<% if instance['window'] -%>
window: <%= instance['window'] %>
<% end -%>
<% if @include_content -%>
include_content: <%= @include_content %>
<% if instance['include_content'] -%>
include_content: <%= instance['include_content'] %>
<% end -%>
<% if @collect_response_time -%>
collect_response_time: <%= @collect_response_time %>
<% if instance['collect_response_time'] -%>
collect_response_time: <%= instance['collect_response_time'] %>
<% end -%>
disable_ssl_validation: <%= @disable_ssl_validation %>
<% if @headers and ! @headers.empty? -%>
disable_ssl_validation: <%= instance['disable_ssl_validation'] %>
<% if instance['headers'] and ! instance['headers'].empty? -%>
headers:
<%- Array(@headers).each do |header| -%>
<%- Array(instance['headers']).each do |header| -%>
<%- if header != '' -%>
<%= header %>
<%- end -%>
<%- end -%>
<% end -%>
<% if @tags and ! @tags.empty? -%>
<% if instance['tags'] and ! instance['tags'].empty? -%>
tags:
<%- Array(@tags).each do |tag| -%>
<%- Array(instance['tags']).each do |tag| -%>
<%- if tag != '' -%>
- <%= tag %>
<%- end -%>
<%- end -%>
<% end -%>
<% if @contacts and ! @contacts.empty? -%>
<% if instance['contacts'] and ! instance['contacts'].empty? -%>
notify:
<%- Array(@contacts).each do |contact| -%>
<%- Array(instance['contacts']).each do |contact| -%>
<%- if contact != '' -%>
- <%= contact %>
<%- end -%>
<%- end -%>
<% end -%>

<% end -%>