Version information
This version is compatible with:
- , ,
Start using this module
Add this module to your Puppetfile:
mod 'camptocamp-collectd', '1.0.2'
Learn more about managing modules with a PuppetfileDocumentation
Puppet Module for Collectd
Example Usage
The following example will install, configure and run collectd. Also it will load the cpu, memory, disk, apache and postgresql plugins after installing all the needed dependencies. And finally define instance settings for the apache and postgresql plugins.
include 'collectd'
collectd::plugin { ['cpu', 'memory', 'disk']: }
collectd::config::plugin { 'monitor apache on www1':
plugin => 'apache',
settings => '
<Instance "www1">
URL "http://www1.example.com/mod_status?auto"
</Instance>
',
}
collectd::config::plugin { 'monitor apache on www2':
plugin => 'apache',
settings => '
<Instance "www2">
URL "http://www2.example.com/mod_status?auto"
</Instance>
',
}
collectd::config::plugin { 'my postgresql plugin config':
plugin => 'postgresql',
settings => template('/path/to/some/template.erb'),
}
collectd::config::plugin { 'my plugin with hashed config':
plugin => 'interface',
settings => {
'interface' => ['lo','sit0'],
'ignore_selected' => true
}
}
collectd::config::plugin { 'another one':
plugin => 'df',
settings => {
'mount_point' => [ '/afs', '/boot', '/proc' ],
'fs_type' => [ 'nfs', 'devpts', 'iso9660' ],
'ignore_selected' => true,
'values_percentage' => true,
'report_inodes' => true,
'report_by_device' => false
}
}
If you want to completely disable package management, do the following:
class { 'collectd':
manage_package => false
}
You'll also find more usage examples in spec/fixtures/manifests/site.pp
.
Be sure to have a look at the READMEs and comments in the files created under /etc/collectd/
to make sense of how the configuration is structured.
Classes and Defined Types
This module defines the following classes and defined types:
collectd
collectd::plugin
collectd::config::plugin
collectd::config::global
collectd::config::type
collectd::config::chain
There is detailed inline documentation for each of these classes/types.
The following classes and types are used behind the scenes, and in most cases you shoudn't need to care about them:
collectd::package
collectd::config
collectd::service
collectd::setup::defaultplugins
collectd::setup::loadplugin
collectd::setup::registerplugin
collectd::setup::settings
Client-Server setup
To avoid making assumptions on how you're supposed to organise your collectd infrastructure, setting up how metrics are passed along from one node to another is left to you. One caveat you should be aware of though: collectd instances receiving metrics from other ones must know about the Dataset type of these metrics. To ease sharing this information, this puppet module exports them from collectd::config::type
, which allows easy collection on other nodes. Short example:
If you declare something like this on emitting instance(s):
collectd::config::type { 'haproxy':
value => 'bin:COUNTER:0:U, bout:COUNTER:0:U',
}
Then you can/should collect the exported Dataset type(s) on the receiving instance(s) using the following statement. This will ensure the above haproxy
DS is present in /etc/collectd/custom-types.db
.
Concat::Fragment <<| tag == 'collectd_typesdb' |>>
Dependencies
This module relies on stdlib and concat.
If you install collectd-dsl on your puppetmaster, you'll be able to use the collectd_dsl()
function in your manifests and templates.
collectd::config::plugin { 'configure df':
type => 'df',
settings => collectd_dsl('
device "/dev/sda1"
report_reserved :true
report_inodes :true
'),
}
Moreover, if settings
is given a Hash, it will call collectd_dsl()
using a recursive procedure, where nested hashes will be treated as new blocks for collectd_dsl()
, and arrays will cause multiple lines with the same key.
The following code:
collectd::config::plugin { 'threshold_processes':
plugin => 'threshold',
settings => {
'plugin "processes"' => {
'type "fork_rate"' => {
'percentage' => false,
'warning_max' => 1 * 1500
}
}
}
}
will lead to the following collectd config:
<Plugin threshold>
<Plugin "processes">
<Type "fork_rate">
Percentage false
WarningMax 1500
</Type>
</Plugin>
</Plugin>
Note the way collectd_dsl()
does the conversion of all the keys to CamelCase, and observe how the boolean is correctly translated to an unquoted keyword in collectd (which is important because collectd's liboconfig grammar is typed). Also note the necessity to pass the number 1500
in numeric context by mulitplying it by 1
, as puppet < 4.x would treat it as a regular string, which would cause the collectd threshold plugin to fail.
Here is the same config as it would appear in hiera:
threshold_processes:
plugin: threshold
settings:
'plugin "processes"':
"type fork_rate":
percentage: false
warning_max: 1500
Note that hiera correctly types both booleans and numbers.
Tests
There a some rspec tests in the spec/
directory.
The following instructions will hopefully setup the stuff required for running the tests (the first 3 are optional):
$ curl -L get.rvm.io | bash -s stable
$ rvm install 1.9.3
$ rvm use --create 1.9.3@puppet-collectd
$ gem install rspec-puppet puppetlabs_spec_helper puppet-lint puppet
And then, run the tests:
$ rake lint
$ rake spec
Change Log
1.0.2 (2019-08-05)
Merged pull requests:
1.0.1 (2019-07-30)
Merged pull requests:
- Add basic acceptance test #44 (raphink)
- Fix package versions to avoid conflicts with plugin deps #43 (raphink)
1.0.0 (2019-06-27)
Merged pull requests:
- Update syntax #42 (raphink)
- Fix plugins duplicate dependencies #41 (raphink)
- Fix tests #39 (raphink)
0.2.6 (2019-04-17)
Merged pull requests:
- use version for plugin dependency resolution #37 (JGodin-C2C)
- Fix libmnl on squeeze #36 (mcanevet)
- Don't try to install libmnl on Debian \< 7 #35 (mcanevet)
- Create missing variable #34 (JGodin-C2C)
- Do not pass ensure to concat::fragment #33 (raphink)
- Configure systemd to allow capacities for the plugins that needs it. #32 (JGodin-C2C)
- feature/quickfix debian8 libmnl0 dependency #31 (JGodin-C2C)
0.2.3 (2018-06-04)
0.2.2 (2018-03-14)
0.2.1 (2018-03-14)
0.1.14 (2018-03-14)
0.2.0 (2017-08-11)
Merged pull requests:
0.1.13 (2017-01-30)
Merged pull requests:
- Fix collectd_version fact #29 (raphink)
- added support for write_prometheus plugin on Debian #28 (cjeanneret)
- Ubuntu 16.04 has libgcrypt20 #27 (mcanevet)
0.1.12 (2016-06-20)
0.1.11 (2015-10-22)
0.1.10 (2015-08-21)
Merged pull requests:
0.1.9 (2015-06-26)
Merged pull requests:
- [WIP] Fix containment issue #24 (mcanevet)
- Remove pre-4.6 support #23 (mcanevet)
- Use ensure_packages instead of virtual resources #22 (mcanevet)
- Code simplification #20 (mcanevet)
0.1.8 (2015-05-28)
Merged pull requests:
- Add missing anchors #21 (mcanevet)
- Add support for Debian jessie, Ubuntu 12.04 and 14.04 #19 (mcanevet)
0.1.7 (2015-05-26)
0.1.6 (2015-05-26)
0.1.5 (2015-05-26)
0.1.4 (2015-05-25)
Merged pull requests:
0.1.3 (2015-05-13)
0.1.2 (2015-05-12)
0.1.1 (2015-04-27)
Fixed bugs:
- This module is no longer compatible with recent changes in the concat module #6
Closed issues:
- Request for Info: Open to STDMOD additions? #7
Merged pull requests:
- use libgcrypt20 on jessie #16 (saimonn)
- F/optional package management #14 (faxm0dem)
- Fix bug where order of key/values was changed erradically #11 (faxm0dem)
- F/collectd dsl from hash #9 (faxm0dem)
- Fix strict_variables issue during first run #8 (mcanevet)
- Minor fixes #5 (mremy)
- Don't install lvm plugin on RH4 and RHEL5 #4 (mremy)
- implement optional private flag for configuration snippets #3 (mfournier)
- added precise version for some default programs #2 (cjeanneret)
- collectd::config::plugin - Validate $collectd::config::pluginsconfdir, not $full_pathname #1 (raphink)
* This Change Log was automatically generated by github_changelog_generator
Dependencies
- puppetlabs/concat (>=2.0.0)
- puppetlabs/stdlib (>=4.2.0 <7.0.0)
Copyright (C) 2013 Camptocamp SA Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.