collectd: Install and configure collectd
The *collectd* role, with its corresponding `collectd.yml` playbook, installs *collectd* onto the managed node and manages basic configuration for it. By default, it will enable several plugins, including the `network` plugin. The `collectd_disable_plugins` variable can be set to a list names of plugins that should NOT be enabled. The default configuration for the `network` plugin instructs *collectd* to send metrics to the default IPv6 multicast group. Any host that has joined this group and is listening on the specified UDP port (default 25826) can receive the data. This allows for nearly zero configuration, as the configuration does not need to be updated if the name or IP address of the receiver changes. This configuration is ready to be deployed without any variable changes to all Pyrocufflink servers. Once *collectd* is running on the servers, we can set up a *collectd* instance to receive the data and store them in a time series database (i.e. Prometheus).
This commit is contained in:
21
collectd.yml
Normal file
21
collectd.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
- hosts: collectd
|
||||
roles:
|
||||
- role: collectd
|
||||
tags:
|
||||
- collectd
|
||||
|
||||
- hosts: prometheus
|
||||
roles:
|
||||
- role: collectd-prometheus
|
||||
tags:
|
||||
- collectd
|
||||
- collectd-prometheus
|
||||
|
||||
- hosts: collectd
|
||||
tasks:
|
||||
- name: ensure collectd is running
|
||||
service:
|
||||
name: collectd
|
||||
state: started
|
||||
tags:
|
||||
- service
|
||||
7
roles/collectd/defaults/main.yml
Normal file
7
roles/collectd/defaults/main.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
collectd_default_config: true
|
||||
collectd_load_network_plugin: true
|
||||
collectd_network_servers:
|
||||
- ff18::efc0:4a42
|
||||
collectd_network_listen: []
|
||||
|
||||
collectd_disable_plugins: []
|
||||
4
roles/collectd/handlers/main.yml
Normal file
4
roles/collectd/handlers/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
- name: restart collectd
|
||||
service:
|
||||
name: collectd
|
||||
state: restarted
|
||||
35
roles/collectd/tasks/main.yml
Normal file
35
roles/collectd/tasks/main.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
- name: load distribution-specific values
|
||||
include_vars: '{{ item }}'
|
||||
with_first_found:
|
||||
- '{{ ansible_distribution }}.yml'
|
||||
- defaults.yml
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: ensure collectd is installed
|
||||
package:
|
||||
name: '{{ collectd_packages }}'
|
||||
state: present
|
||||
tags:
|
||||
- install
|
||||
|
||||
- name: ensure collectd is configured
|
||||
template:
|
||||
src: collectd.conf.j2
|
||||
dest: /etc/collectd.conf
|
||||
mode: '0644'
|
||||
notify:
|
||||
- restart collectd
|
||||
tags:
|
||||
- collectd-config
|
||||
|
||||
- name: ensure collectd network plugin is configured
|
||||
template:
|
||||
src: collectd-network.conf.j2
|
||||
dest: /etc/collectd.d/network.conf
|
||||
mode: '0644'
|
||||
notify:
|
||||
- restart collectd
|
||||
tags:
|
||||
- collectd-config
|
||||
- collectd-network
|
||||
20
roles/collectd/templates/collectd-network.conf.j2
Normal file
20
roles/collectd/templates/collectd-network.conf.j2
Normal file
@@ -0,0 +1,20 @@
|
||||
{% if collectd_load_network_plugin %}
|
||||
LoadPlugin network
|
||||
|
||||
{% endif %}
|
||||
<Plugin network>
|
||||
{% for server in collectd_network_servers %}
|
||||
{% if server is string %}
|
||||
Server "{{ server }}"
|
||||
{% else %}
|
||||
Server "{{ server.host }}" {{ server.port }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for listen in collectd_network_listen %}
|
||||
{% if listen is string %}
|
||||
Listen "{{ listen }}"
|
||||
{% else %}
|
||||
Listen "{{ listen.host }}" {{ listen.port}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</Plugin>
|
||||
2111
roles/collectd/templates/collectd.conf.j2
Normal file
2111
roles/collectd/templates/collectd.conf.j2
Normal file
File diff suppressed because it is too large
Load Diff
4
roles/collectd/vars/defaults.yml
Normal file
4
roles/collectd/vars/defaults.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
collectd_packages:
|
||||
- collectd
|
||||
- collectd-chrony
|
||||
- collectd-disk
|
||||
Reference in New Issue
Block a user