collectd
Ansible role collectd
An Ansible role for installing collectd
on RHEL/CentOS 7. Specifically, the responsibilities of this role are to:
- Install collectd, and, optionally, collectd-web
- Set up the host either as a client or a server
The following plugins are activated out-of-the-box:
- cpu
- interface
- load
- memory
- network
- rrdtool (on the server)
Activating other plugins is out of the scope of this role. To do this yourself, make sure a configuration file is placed into the folder collectd_include_dir
(usually /etc/collectd.d/
) before this role is applied. For more information on how to write a collectd configuration file, see the collectd.conf(5)
man page.
The network traffic generated by collectd is currently still unencrypted, so it is probably not recommended to use this in production.
Getting started
In order for this role to work, it is necessary to set the role variable collectd_server
to the IP address of the host that will collect all the metrics generated by other hosts. Make sure all hosts can access the value of collectd_server
(e.g. in group_vars/all.yml
). The host that matches this IP address will be set up as the server, other hosts will be set up as clients that send their metrics to the server. See the test playbook for a minimal example.
By default, collectd-web
will be installed on the server. If you don't want this (e.g. because you want to do graphing with another tool like Graphite), set the variable collectd_web_enabled
to false
.
Requirements
No specific requirements
Role Variables
This is a list of the configurable role variables. Variables are not required unless indicated.
Variable | Default | Comments (type) |
---|---|---|
collectd_interval |
10 | Sets the interval for collecting metrics, in seconds. |
collectd_log_level |
info | Specifies the verbosity of logging. Values: info, notice, warning, err. |
collectd_read_threads |
5 | Number of threads to start for reading plugins. |
collectd_server |
- | Required The IP address of the host that will collect all generated metrics. |
collectd_server_port |
- | Alternative port number for the collectd server (default is 25826 over UDP) |
collectd_timeout |
2 | Consider a value list "missing" when no update has been received for this number of iterations |
collectd_web_enabled |
true | Specifies whether collectd-web should be enabled on the server. |
collectd_write_threads |
5 | Number of threads to start for dispatching value lists to write plugins. |
Dependencies
No dependencies.
Example Playbook
See the test playbook
Testing
The tests
directory contains tests for this role in the form of a Vagrant environment. After executing vagrant up
in that directory, you should get an environment with three VM's, attached to VirtualBox's default host only network (with IP 192.168.56.0/24).
Host name | IP | Role |
---|---|---|
collectdsrv |
192.168.56.40 | collectd server |
collectdcln1 |
192.168.56.41 | collectd client |
collectdcln2 |
192.168.56.42 | collectd client |
The clients send their metrics to collectdsrv
. On the server, collectd-web
is also enabled, and you can view the generated graphs by opening a browser on your host system and surfing to http://192.168.56.40/collectd/.
If you want, you can set up from 1 to 9 clients, by editing the Vagrantfile and setting the desired number of clients in the line:
# The number of hosts that send their data to the collectd server
# Assumed to be at most 9.
NUM_CLIENTS = 2
The directory tests/roles/collectd
is a symbolic link that should point to the root of this project in order to work. To create it, do
$ cd tests/
$ mkdir roles
$ ln -frs ../../PROJECT_DIR roles/collectd
You may want to change the base box into one that you like. The current one is based on Box-Cutter's CentOS Packer template.
The playbook test.yml
applies the role to a VM, setting role variables.
Contributing
Issues, feature requests, ideas are appreciated and can be posted in the Issues section. Pull requests are also very welcome. Preferably, create a topic branch and when submitting, squash your commits into one (with a descriptive message).
License
BSD
Author Information
Bert Van Vreckem (bert.vanvreckem@gmail.com)
ansible-galaxy install christophershoemaker/ansible-role-collectd