├── LICENSE
├── README.md
├── defaults
└── main.yml
├── files
├── collectd-coretemp.sh
└── coretemp.modules
├── handlers
└── main.yml
├── meta
└── main.yml
├── tasks
├── centos.yml
├── debian.yml
└── main.yml
├── templates
├── collectd.conf.j2
└── plugin-configs
│ ├── cpu.conf.j2
│ ├── df.conf.j2
│ ├── disk.conf.j2
│ ├── exec.conf.j2
│ ├── interface.conf.j2
│ ├── librato.conf.j2
│ ├── load.conf.j2
│ ├── memory.conf.j2
│ ├── network.conf.j2
│ ├── rrdtool.conf.j2
│ ├── swap.conf.j2
│ ├── syslog.conf.j2
│ ├── vmem.conf.j2
│ └── write_graphite.conf.j2
└── tests
└── main.yml
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Wizcorp
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | collectd role
2 | ===============
3 |
4 | This role takes care of adding collectd to any given server.
5 |
6 | It can be used to:
7 |
8 | 1. Collect metrics about a machines, and optionally forward them to an aggregation machine.
9 |
10 | 2. Create an aggregation machine, which will receive the metrics from a given set of machine within the same datacenter.
11 | In this case too, metrics can optionally be forwarded to another service.
12 |
13 | Configuration
14 | --------------
15 |
16 | ### For any machines
17 |
18 | Simply add the collector role to your playbook.
19 |
20 | By default, we will save all metrics to RRD files under `/var/lib/collectd/rrd/${hostname}`.
21 |
22 | ### For forwarding machines
23 |
24 | #### Inventory
25 |
26 | Normally, we put all aggregation on a single machine.
27 | However, it is possible to decouple them, and provision separate machines for any aggregators we might have.
28 | This example demonstrate how to create a dedicated collectd aggregator.
29 | `collectd_forwarder` defines the host that is the dedicated collectd aggregator. Default is an empty string, '',
30 | which configures the network plugin to not send to a collectd aggregator.
31 |
32 |
33 | ```ini
34 | [collectd:children]
35 | collectd-somedc-prod
36 |
37 | [collectd-somedc-prod]
38 | collectd1.somedc.prod ansible_ssh_host=10.0.1.111
39 |
40 | [... skipping ...]
41 | [somedc-prod:children]
42 | collectd-somedc-prod
43 |
44 | [somedc-prod:vars]
45 | collectd_forwarder = collectd1.somedc.prod
46 |
47 | #
48 | # Optional: if you are aggregating logs with logstash
49 | # and are using ElasticSearch and Kibana, you might
50 | # want to also keep track of your metrics through
51 | # Kibana. If so, simply add the following to your
52 | # global configuration - keep in mind that
53 | # activating this will turn off any other
54 | # forwarding you might have configured in
55 | # favor of sending all entries to logstash
56 | #
57 | logstash_forwarder = collectd2.somedc.prod
58 |
59 | collectd_forward_to_logstash = true
60 | ```
61 |
62 | The following may also be added to your inventory.
63 |
64 | * `collectd_interval`: at what interval in seconds to take measurements (default: 60)
65 | * `check_disk`: a value which we will use to select what disk to monitor (default: xvde)
66 | * `collectd_df_fs_type`: the file system type to monitor (Collectd 5.4 default: ext4. Collectd 5.5 default: undefined)
67 | * `collectd_df_device`: the dev device to monitor.
68 | * `collectd_df_mountpoint`: the mount point to monitor.
69 | * `collectd_df_IgnoreSelected`: [see wiki](https://collectd.org/wiki/index.php/Plugin:DF#Parameters) (default: false)
70 | * `collectd_df_ReportByDevice`: [see wiki](https://collectd.org/wiki/index.php/Plugin:DF#Parameters) (default: false)
71 | * `collectd_df_ReportInodes`: [see wiki](https://collectd.org/wiki/index.php/Plugin:DF#Parameters) (default: false)
72 | * `collectd_df_ValuesAbsolute`: [see wiki](https://collectd.org/wiki/index.php/Plugin:DF#Parameters) (default: true)
73 | * `collectd_df_ValuesPercentage`: [see wiki](https://collectd.org/wiki/index.php/Plugin:DF#Parameters) (default: false)
74 | * `monitor_coretemp`: set to true if you want to monitor coretemp (only useful on real hardware)
75 | * `private_ip`: set to the IP address of the `collectd_forwarder` if `collectd_forwarder` has multiple IPs. Example:
76 | ```
77 | collectd1.somedc.prod ansible_ssh_host=10.0.1.111 private_ip=172.16.1.111
78 | ```
79 |
80 | ### Plugin configuration
81 |
82 | The `collectd_plugins` variable defines the plugins to be loaded. Default plugins are below:
83 |
84 | ```
85 | - syslog
86 | - cpu
87 | - interface
88 | - load
89 | - memory
90 | - vmem
91 | - swap
92 | - disk
93 | - rrdtool
94 | - network
95 | - librato
96 | - exec
97 | - write_graphite
98 | ```
99 |
100 |
101 | #### [Disk](https://collectd.org/wiki/index.php/Plugin:Disk)
102 |
103 |
104 | Default: xvde
105 |
106 | ```
107 | check_disk: xvde
108 | ```
109 |
110 | #### [DF](https://collectd.org/wiki/index.php/Plugin:DF)
111 |
112 | All options are optional.
113 |
114 | The following should be set as an array.
115 | Example 1: (Single value)
116 | ```
117 | collectd_df_device: '["/dev/xvda1"]'
118 | collectd_df_mountpoint: '["/"]'
119 | collectd_df_fs_type: '["xfs"]'
120 | ```
121 | Example 2: (Multiple values)
122 | ```
123 | collectd_df_device: '["/dev/xvda1","/dev/xvdb1"]'
124 | collectd_df_mountpoint: '["/","/data"]'
125 | collectd_df_fs_type: '["xfs","ext4"]'
126 | ```
127 |
128 | You can change the rest of the defaults.
129 | ```
130 | collectd_df_IgnoreSelected: false
131 | collectd_df_ReportByDevice: false
132 | collectd_df_ReportInodes: false
133 | collectd_df_ValuesAbsolute: true
134 | collectd_df_ValuesPercentage: false
135 | ```
136 |
137 | ### Install plugins
138 |
139 | To indicate the plugins that you would like installed, list all the plugins in the `packages` variable in
140 | your `group_vars` folder.
141 |
142 | For example, below installs only the `collect-rrdtools`, `collectd-rrdtool` and `collectd-iptables` plugins.
143 |
144 | ```
145 | packages:
146 | - collectd-rrdcached
147 | - collectd-rrdtool
148 | - collectd-iptables
149 | ```
150 |
151 | If you do not set `packages`, the following default packages that will be installed.
152 |
153 | ```
154 | - git
155 | - collectd
156 | - collectd-amqp
157 | - collectd-apache
158 | - collectd-bind
159 | - collectd-curl
160 | - collectd-curl_json
161 | - collectd-curl_xml
162 | - collectd-dbi
163 | - collectd-dns
164 | - collectd-generic-jmx
165 | - collectd-iptables
166 | - collectd-ipvs
167 | - collectd-java
168 | - collectd-lvm
169 | - collectd-mysql
170 | - collectd-netlink
171 | - collectd-notify_desktop
172 | - collectd-postgresql
173 | - collectd-rrdcached
174 | - collectd-rrdtool
175 | - collectd-sensors
176 | - collectd-snmp
177 | - collectd-write_riemann
178 | ```
179 |
180 | The following command will list the possible packages that can be installed:
181 |
182 | - CentOS 6: `sudo yum --enablerepo="epel,gf-plus" list available | grep collectd-`
183 | - CentOS 7: `sudo yum --enablerepo="epel" list available | grep collectd-`
184 |
185 |
186 | ### Roles addition
187 |
188 | It is possible for any roles to add their own custom metric collection configuration.
189 |
190 | In `myrole/templates/collectd.conf.j2`:
191 |
192 | ```
193 |
194 | ...
195 |
196 | ```
197 |
198 | Then, in `myrole/tasks/main.yml`:
199 |
200 | ```yaml
201 | - name: Adding collectd monitoring for myrole
202 | template: >
203 | src=collectd.conf.j2
204 | dest=/etc/collectd.d/myrole.conf
205 | notify:
206 | - Restart collectd
207 | tags:
208 | - myrole
209 | - files
210 | - collectd
211 | ```
212 |
213 | ### Execution
214 |
215 | #### For any machines
216 |
217 | Simply follow the standard provisioning method.
218 |
219 | ### For the collector machine
220 |
221 | When provisioning with this role, you can also add
222 | [Librato](https://www.librato.com/) and
223 | [Graphite](http://graphite.wikidot.com/) support.
224 |
225 | As you should not add any credentials to your inventory,
226 | it should be done by using `--extra-vars` as described below.
227 |
228 | #### Librato
229 |
230 | ```
231 | --extra-vars="use_librato=true" \
232 | --extra-vars="librato_email=some@email.com" \
233 | --extra-vars="librato_token=API-KEY"
234 | ```
235 |
236 | ### Graphite
237 |
238 | ```
239 | --extra-vars="use_graphite=true" \
240 | --extra-vars="graphite_host=some.host.com" \
241 | --extra-vars="graphite_port="
242 | ```
243 |
244 | See also
245 | --------
246 |
247 | * [collectd](http://collectd.org/)
248 |
--------------------------------------------------------------------------------
/defaults/main.yml:
--------------------------------------------------------------------------------
1 | monitor_coretemp: false
2 | collectd_forward_to_logstash: false
3 |
4 | collectd_forwarder: ''
5 |
6 | use_librato: false
7 | use_graphite: false
8 |
9 | collectd_plugins:
10 | - syslog
11 | - cpu
12 | - interface
13 | - load
14 | - memory
15 | - vmem
16 | - swap
17 | - disk
18 | - rrdtool
19 | - network
20 | - librato
21 | - exec
22 | - write_graphite
23 |
24 | packages:
25 | - git
26 | - collectd
27 | - collectd-amqp
28 | - collectd-apache
29 | - collectd-bind
30 | - collectd-curl
31 | - collectd-curl_json
32 | - collectd-curl_xml
33 | - collectd-dbi
34 | - collectd-generic-jmx
35 | - collectd-iptables
36 | - collectd-ipvs
37 | - collectd-java
38 | - collectd-lvm
39 | - collectd-mysql
40 | - collectd-netlink
41 | - collectd-notify_desktop
42 | - collectd-postgresql
43 | - collectd-rrdcached
44 | - collectd-rrdtool
45 | - collectd-snmp
46 | - collectd-write_riemann
47 |
--------------------------------------------------------------------------------
/files/collectd-coretemp.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cd /sys/devices/platform/coretemp.0
4 |
5 | host=${COLLECTD_HOSTNAME:=`hostname -f`}
6 |
7 | while
8 | true
9 | do
10 | LIST=$(ls | grep temp | cut -d"_" -f1 | sort | uniq)
11 |
12 | for f in ${LIST}
13 | do
14 | timestamp=$(date +%s)
15 | label="$(cat ${f}_label)"
16 |
17 | if
18 | ! (echo ${label} | grep -q "Core")
19 | then
20 | continue
21 | fi
22 |
23 | cpunum="$(echo ${label} | sed "s/Core //")"
24 | value="$(cat ${f}_input)"
25 |
26 | echo "PUTVAL \"${host}/core-temp/gauge-core_${cpunum}\" ${timestamp}:${value}"
27 | done
28 |
29 | sleep ${COLLECTD_INTERVAL:-10} || true
30 | done
31 |
--------------------------------------------------------------------------------
/files/coretemp.modules:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | exec /sbin/modprobe coretemp >/dev/null 2>&1
4 |
--------------------------------------------------------------------------------
/handlers/main.yml:
--------------------------------------------------------------------------------
1 | - name: "Restart collectd"
2 | service: >
3 | name=collectd
4 | state=restarted
5 | tags:
6 | - collectd
7 |
--------------------------------------------------------------------------------
/meta/main.yml:
--------------------------------------------------------------------------------
1 | galaxy_info:
2 | author: Marc Trudel
3 | description: This role takes care of adding collectd to any given server
4 | company: Wizcorp K.K.
5 | license: MIT
6 | min_ansible_version: 1.8.1
7 | platforms:
8 | - name: EL
9 | versions:
10 | - 6
11 | - 7
12 | - name: Debian
13 | versions:
14 | - wheezy
15 | - jessie
16 | categories:
17 | - monitoring
18 | dependencies:
19 | - role: AerisCloud.repos
20 | repositories:
21 | centos6:
22 | - epel
23 | centos7:
24 | - epel
25 | - role: AerisCloud.yum
26 |
--------------------------------------------------------------------------------
/tasks/centos.yml:
--------------------------------------------------------------------------------
1 | - name: "Set collectd's config file destination"
2 | set_fact: >
3 | collectd_config_dest=/etc/collectd.conf
4 | collectd_d_config_dir=/etc/collectd.d
5 | tags:
6 | - collectd
7 |
8 | - name: "Clean old packages"
9 | yum: >
10 | name={{ item }}
11 | state=absent
12 | with_items:
13 | - collectd-python
14 | - collectd-hddtemp
15 | - libcollectdclient
16 | tags:
17 | - collectd
18 | - pkgs
19 |
20 | - name: "Install Ghettoforge repo"
21 | yum: >
22 | name=http://mirror.symnds.com/distributions/gf/el/6/gf/x86_64/gf-release-6-10.gf.el6.noarch.rpm
23 | state=present
24 | when: ansible_distribution_major_version|int == 6
25 | tags:
26 | - collectd
27 | - pkgs
28 | - repos
29 |
30 | - name: "Install required packages"
31 | yum : >
32 | name={{ item }}
33 | enablerepo=epel,gf-plus
34 | state=latest
35 | with_items: "{{ packages }}"
36 | when: ansible_distribution_major_version|int == 6
37 | tags:
38 | - collectd
39 | - pkgs
40 |
41 | - name: "Install required packages"
42 | yum : >
43 | name={{ item }}
44 | enablerepo=epel
45 | state=latest
46 | with_items: "{{ packages }}"
47 | when: ansible_distribution_major_version|int > 6
48 | tags:
49 | - collectd
50 | - pkgs
51 |
52 | - name: "Load coretemp module on boot"
53 | copy: >
54 | src=coretemp.modules
55 | dest=/etc/sysconfig/modules/coretemp.modules
56 | owner=root
57 | group=root
58 | mode=0700
59 | when: monitor_coretemp and ansible_distribution_major_version|int == 6
60 | tags:
61 | - collectd
62 | - files
63 |
64 | - name: "Load coretemp module on boot"
65 | copy: >
66 | content=coretemp
67 | dest=/etc/modules-load.d/coretemp.conf
68 | owner=root
69 | group=root
70 | mode=0600
71 | when: monitor_coretemp and ansible_distribution_major_version|int == 7
72 | tags:
73 | - collectd
74 | - files
75 |
76 | - name: "Get Collectd version"
77 | shell: |
78 | executable=/bin/bash
79 | v=$(rpm -qa --queryformat %{version} collectd); echo "${v%.*}"
80 | register: collectd_version
81 | tags:
82 | - collectd
83 | - files
84 |
85 | - name: "Set version"
86 | set_fact:
87 | installed_version: "{{ collectd_version.stdout }}"
88 | tags:
89 | - collectd
90 | - files
91 |
--------------------------------------------------------------------------------
/tasks/debian.yml:
--------------------------------------------------------------------------------
1 | - name: "Set collectd's config file destination"
2 | set_fact: >
3 | collectd_config_dest=/etc/collectd/collectd.conf
4 | collectd_d_config_dir=/etc/collectd/collectd.conf.d
5 | tags:
6 | - collectd
7 |
8 | - name: "Install required packages"
9 | apt : >
10 | name={{ item }}
11 | state=latest
12 | with_items:
13 | - git
14 | - collectd
15 | - collectd-core
16 | - collectd-utils
17 | tags:
18 | - install
19 | - collectd
20 | - pkgs
21 |
22 | - name: "Load coretemp module on boot"
23 | lineinfile: >
24 | dest=/etc/modules
25 | line=coretemp
26 | when: monitor_coretemp
27 | tags:
28 | - collectd
29 | - files
30 |
31 | - name: "Get Collectd version"
32 | shell: |
33 | executable=/bin/bash
34 | v=$(dpkg-query --showformat='${Version}' --show collectd); echo "${v%.*}"
35 | register: collectd_version
36 | tags:
37 | - collectd
38 | - files
39 |
40 | - name: "Set version"
41 | set_fact:
42 | installed_version: "{{ collectd_version.stdout }}"
43 | tags:
44 | - collectd
45 | - files
46 |
--------------------------------------------------------------------------------
/tasks/main.yml:
--------------------------------------------------------------------------------
1 | - include: centos.yml
2 | when: ansible_distribution == "CentOS"
3 |
4 | - include: debian.yml
5 | when: ansible_distribution == "Debian"
6 |
7 | #####################
8 | # Common
9 | - name: "Ensure the collectd exec module directory exists"
10 | file: >
11 | path=/opt/collectd-exec-modules
12 | state=directory
13 | tags:
14 | - collectd
15 | - pkgs
16 | - libs
17 |
18 | - name: "Make sure /etc/collectd.d is present"
19 | file: >
20 | path=/etc/collectd.d
21 | state=directory
22 | tags:
23 | - collectd
24 | - files
25 | - configs
26 |
27 | - name: "Upload plugin configs"
28 | template: >
29 | src=plugin-configs/{{ item }}.conf.j2
30 | dest={{ collectd_d_config_dir }}/{{ item }}.conf
31 | mode=0644
32 | with_items: "{{ collectd_plugins }}"
33 | notify:
34 | - Restart collectd
35 | tags:
36 | - collectd
37 | - files
38 | - configs
39 |
40 | - name: "Install coretemp plugin for collectd"
41 | copy: >
42 | src=collectd-coretemp.sh
43 | dest=/opt/collectd-exec-modules/
44 | mode=0755
45 | owner=root
46 | group=root
47 | notify:
48 | - Restart collectd
49 | tags:
50 | - collectd
51 | - files
52 |
53 | - name: "Install /etc/collectd.conf"
54 | template: >
55 | src=collectd.conf.j2
56 | dest={{ collectd_config_dest }}
57 | mode=0644
58 | notify:
59 | - Restart collectd
60 | tags:
61 | - collectd
62 | - files
63 | - configs
64 |
65 | - name: "Add the coretemp kernel module"
66 | modprobe: >
67 | name=coretemp
68 | state=present
69 | when: monitor_coretemp
70 | tags:
71 | - collectd
72 | - files
73 | - configs
74 |
75 | - name: "Make sure collectd is running"
76 | service: >
77 | name=collectd
78 | state=started
79 | enabled=yes
80 | runlevel=5
81 | tags:
82 | - collectd
83 |
--------------------------------------------------------------------------------
/templates/collectd.conf.j2:
--------------------------------------------------------------------------------
1 | #
2 | # Config file for collectd(1).
3 | # Please read collectd.conf(5) for a list of options.
4 | # http://collectd.org/
5 | #
6 |
7 | ##############################################################################
8 | # Global #
9 | #----------------------------------------------------------------------------#
10 | # Global settings for the daemon. #
11 | ##############################################################################
12 |
13 | Hostname "{{ server_hostname | default(inventory_hostname) }}"
14 | FQDNLookup false
15 | #BaseDir "/var/lib/collectd"
16 | #PIDFile "/var/run/collectd.pid"
17 | #PluginDir "/usr/lib64/collectd"
18 | #TypesDB "/usr/share/collectd/types.db"
19 |
20 | #----------------------------------------------------------------------------#
21 | # When enabled, plugins are loaded automatically with the default options #
22 | # when an appropriate block is encountered. #
23 | # Disabled by default. #
24 | #----------------------------------------------------------------------------#
25 | AutoLoadPlugin false
26 | {% if installed_version|version_compare("5.5", ">=") %}
27 | #----------------------------------------------------------------------------#
28 | # When enabled, internal statistics are collected, using "collectd" as the #
29 | # plugin name. #
30 | # Disabled by default. #
31 | #----------------------------------------------------------------------------#
32 | #CollectInternalStats false
33 | {% endif %}
34 | #----------------------------------------------------------------------------#
35 | # Interval at which to query values. This may be overwritten on a per-plugin #
36 | # base by using the 'Interval' option of the LoadPlugin block: #
37 | # #
38 | # Interval 60 #
39 | # #
40 | #----------------------------------------------------------------------------#
41 | Interval {{ collectd_interval|default('60') }}
42 | {% if installed_version|version_compare("5.5", ">=") %}#MaxReadInterval 86400{% endif %}
43 | #Timeout 2
44 | #ReadThreads 5
45 | #WriteThreads 5
46 |
47 | # Limit the size of the write queue. Default is no limit. Setting up a limit is
48 | # recommended for servers handling a high volume of traffic.
49 | #WriteQueueLimitHigh 1000000
50 | #WriteQueueLimitLow 800000
51 |
52 | Include "/etc/collectd.d"
53 |
--------------------------------------------------------------------------------
/templates/plugin-configs/cpu.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin cpu
2 |
--------------------------------------------------------------------------------
/templates/plugin-configs/df.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin df
2 |
3 | {% if collectd_df_device is defined %}
4 | {% for device in collectd_df_device|from_json %}
5 | Device "{{ device }}"
6 | {% endfor %}
7 | {% endif %}
8 | {% if collectd_df_mountpoint is defined %}
9 | {% for mountpoint in collectd_df_mountpoint|from_json %}
10 | MountPoint "{{ mountpoint }}"
11 | {% endfor %}
12 | {% endif %}
13 | {% if collectd_df_fs_type is defined %}
14 | {% for fs in collectd_df_fs_type|from_json %}
15 | FSType "{{ fs|default('ext4') }}"
16 | {% endfor %}
17 | {% endif %}
18 | {% if collectd_df_IgnoreSelected is defined %} IgnoreSelected "{{ collectd_df_IgnoreSelected|default('false') }}"{% endif %}
19 | {% if collectd_df_ReportByDevice is defined %} ReportByDevice "{{ collectd_df_ReportByDevice|default('false') }}"{% endif %}
20 | {% if collectd_df_ReportInodes is defined %} ReportInodes "{{ collectd_df_ReportInodes|default('false') }}"{% endif %}
21 | {% if collectd_df_ValuesAbsolute is defined %} ValuesAbsolute "{{ collectd_df_ValuesAbsolute|default('true') }}"{% endif %}
22 | {% if collectd_df_ValuesPercentage is defined %} ValuesPercentage "{{ collectd_df_ValuesPercentage|default('false') }}"{% endif %}
23 |
24 |
--------------------------------------------------------------------------------
/templates/plugin-configs/disk.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin disk
2 |
3 | Disk "/^{{ check_disk|default('xvde') }}/"
4 | IgnoreSelected false
5 |
6 |
--------------------------------------------------------------------------------
/templates/plugin-configs/exec.conf.j2:
--------------------------------------------------------------------------------
1 | {% if monitor_coretemp|bool %}
2 | LoadPlugin exec
3 |
4 | Exec nobody "/opt/collectd-exec-modules/collectd-coretemp.sh"
5 |
6 | {% endif %}
7 |
--------------------------------------------------------------------------------
/templates/plugin-configs/interface.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin interface
2 |
3 | Interface "lo"
4 | IgnoreSelected true
5 |
6 |
--------------------------------------------------------------------------------
/templates/plugin-configs/librato.conf.j2:
--------------------------------------------------------------------------------
1 | {% if use_librato|bool %}
2 | {% if (collectd_forwarder == inventory_hostname) or (collectd_forwarder == '') %}
3 | LoadPlugin write_http
4 |
5 | {% if installed_version|version_compare("5.4", "<=") %}
6 |
7 | User "{{ librato_email }}"
8 | Password "{{ librato_token }}"
9 | Format "JSON"
10 |
11 | {% endif %}
12 | {% if installed_version|version_compare("5.5", ">=") %}
13 |
14 | URL "https://collectd.librato.com/v1/measurements"
15 | User "{{ librato_email }}"
16 | Password "{{ librato_token }}"
17 | Format "JSON"
18 |
19 | {% endif %}
20 |
21 | {% endif %}
22 | {% endif %}
23 |
--------------------------------------------------------------------------------
/templates/plugin-configs/load.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin load
2 |
--------------------------------------------------------------------------------
/templates/plugin-configs/memory.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin memory
2 |
--------------------------------------------------------------------------------
/templates/plugin-configs/network.conf.j2:
--------------------------------------------------------------------------------
1 | {% if collectd_forwarder != '' %}
2 | LoadPlugin network
3 |
4 | {% if collectd_forward_to_logstash|bool %}
5 |
6 | Interface "{{ private_interface }}"
7 |
8 | TimeToLive 128
9 | {% elif collectd_forwarder != inventory_hostname %}
10 |
11 | Interface "{{ private_interface }}"
12 |
13 | TimeToLive 128
14 | {% else %}
15 |
16 | Interface "{{ private_interface }}"
17 |
18 | MaxPacketSize 4096
19 | {% endif %}
20 | # statistics about the network plugin itself
21 | ReportStats false
22 |
23 | {% endif %}
24 |
--------------------------------------------------------------------------------
/templates/plugin-configs/rrdtool.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin rrdtool
2 |
3 | DataDir "/var/lib/collectd/rrd"
4 | CacheFlush 120
5 | WritesPerSecond 50
6 |
7 |
--------------------------------------------------------------------------------
/templates/plugin-configs/swap.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin swap
2 |
--------------------------------------------------------------------------------
/templates/plugin-configs/syslog.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin syslog
2 |
3 | LogLevel info
4 |
5 |
--------------------------------------------------------------------------------
/templates/plugin-configs/vmem.conf.j2:
--------------------------------------------------------------------------------
1 | LoadPlugin vmem
2 |
--------------------------------------------------------------------------------
/templates/plugin-configs/write_graphite.conf.j2:
--------------------------------------------------------------------------------
1 | {% if collectd_forwarder == inventory_hostname %}
2 | {% if use_graphite|bool %}
3 | LoadPlugin python
4 |
5 | Interval {{ graphite_interval|default('10') }}
6 |
7 |
8 |
9 | Host "{{ graphite_host }}"
10 | Port "{{ graphite_port }}"
11 | Protocol "udp"
12 | LogSendErrors true
13 | Prefix "collectd"
14 | Postfix "collectd"
15 | StoreRates true
16 | AlwaysAppendDS false
17 | EscapeCharacter "_"
18 |
19 |
20 | {% endif %}
21 | {% endif %}
22 |
--------------------------------------------------------------------------------
/tests/main.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: "Collectd"
3 | playbook:
4 | - hosts: centos:debian
5 | sudo: true
6 | roles:
7 | - role: "@ROLE_NAME@"
8 | private_interface: eth0
9 |
--------------------------------------------------------------------------------