bertvv.collectd
Ansible role collectd
An Ansible role for installing collectd on RHEL/CentOS 7. See the change log for notable changes between versions.
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)
The following plugins can be activated by the user:
- apache
- dbi
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.
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 agents that send their metrics to the server. See the test playbook for a minimal example.
Traffic between the Collectd server and the agents is encrypted. The variable collectd_password contains the password used for encryption. You should change the value of this variable!
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 | Comment |
|---|---|---|
collectd_apache_enabled |
false | If true, enables the Apache plugin |
collectd_dbi_enabled |
false | If true, enables the DBI plugin |
collectd_dbi_host |
127.0.0.1 | IP/hostname of the database server |
collectd_dbi_password |
collectd | Password used to send SQL queries to the database server |
collectd_dbi_username |
collectd | User name used to send SQL queries to the database server |
collectd_interval |
10 | Sets the interval for collecting metrics, in seconds |
collectd_logfile |
- | If set, writes log entries to the specified file |
collectd_log_level |
info | Specifies the verbosity of logging. Values: info, notice, warning, err |
collectd_password |
sekrit | Password used to encrypt traffic between collectd agents and the server |
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_user |
collectd | User name used to encrypt traffic between collectd agents and the server |
collectd_web_enabled |
true | Specifies whether collectd-web should be enabled on the server |
collectd_write_queue_limit_high |
Upper limit for number of metrics in write queue | |
collectd_write_queue_limit_low |
Lower limit for number of metrics in write queue | |
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 molecule directory contains tests for this role in the form of a Vagrant environment. After executing molecule converge from the project root 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 |
|---|---|---|
srv |
192.168.56.40 | collectd server |
cl1 |
192.168.56.41 | collectd client |
cl2 |
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/.
The playbook converge.yml was applied to these VMs.
With molecule verify, you can perform a few black box tests on the collectd server to check if it performs as expected. The tests are based on the BATS test framework and can be found in functional-tests.bats. To see some output from the tests, add the -v option.
You can tear down the test environment with molecule destroy.
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 bertvv.collectd