Puppet Class: collectd

Inherits:
collectd::params
Defined in:
manifests/init.pp

Overview

Parameters:

  • fqdnlookup (Any) (defaults to: true)
  • collectd_hostname (Any) (defaults to: $::hostname)
  • interval (Any) (defaults to: 10)
  • include (Any) (defaults to: [])
  • purge (Any) (defaults to: undef)
  • purge_config (Any) (defaults to: false)
  • recurse (Any) (defaults to: undef)
  • threads (Any) (defaults to: 5)
  • timeout (Any) (defaults to: 2)
  • typesdb (Any) (defaults to: [])
  • write_queue_limit_high (Any) (defaults to: undef)
  • write_queue_limit_low (Any) (defaults to: undef)
  • package_name (Any) (defaults to: $collectd::params::package)
  • version (Any) (defaults to: installed)


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'manifests/init.pp', line 2

class collectd(
  $fqdnlookup             = true,
  $collectd_hostname      = $::hostname,
  $interval               = 10,
  $include                = [],
  $purge                  = undef,
  $purge_config           = false,
  $recurse                = undef,
  $threads                = 5,
  $timeout                = 2,
  $typesdb                = [],
  $write_queue_limit_high = undef,
  $write_queue_limit_low  = undef,
  $package_name           = $collectd::params::package,
  $version                = installed,
) inherits collectd::params {

  $plugin_conf_dir = $collectd::params::plugin_conf_dir
  validate_bool($purge_config, $fqdnlookup)
  validate_array($include, $typesdb)

  package { $package_name:
    ensure   => $version,
    name     => $package_name,
    provider => $collectd::params::provider,
    before   => File['collectd.conf', 'collectd.d'],
  }

  file { 'collectd.d':
    ensure  => directory,
    path    => $collectd::params::plugin_conf_dir,
    mode    => '0750',
    owner   => 'root',
    group   => $collectd::params::root_group,
    purge   => $purge,
    recurse => $recurse,
    notify  => Service['collectd'],
  }

  $conf_content = $purge_config ? {
    true    => template('collectd/collectd.conf.erb'),
    default => undef,
  }

  file { 'collectd.conf':
    path    => $collectd::params::config_file,
    content => $conf_content,
    notify  => Service['collectd'],
  }

  if $purge_config != true {
    # former include of conf_d directory
    file_line { 'include_conf_d':
      ensure => absent,
      line   => "Include \"${collectd::params::plugin_conf_dir}/\"",
      path   => $collectd::params::config_file,
      notify => Service['collectd'],
    }
    # include (conf_d directory)/*.conf
    file_line { 'include_conf_d_dot_conf':
      ensure => present,
      line   => "Include \"${collectd::params::plugin_conf_dir}/*.conf\"",
      path   => $collectd::params::config_file,
      notify => Service['collectd'],
    }
  }

  service { 'collectd':
    ensure  => running,
    name    => $collectd::params::service_name,
    enable  => true,
    require => Package[$package_name],
  }
}