Puppet Class: diamond

Defined in:
modules/diamond/manifests/init.pp

Overview

Parameters:

  • handler (Any) (defaults to: 'diamond.handler.graphite.GraphiteHandler')
  • interval (Any) (defaults to: '60')
  • path_prefix (Any) (defaults to: 'servers')
  • keep_logs_for (Any) (defaults to: '5')
  • service (Any) (defaults to: running)
  • settings (Any) (defaults to: { host => 'localhost', port => '8125', batch => '20', })


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'modules/diamond/manifests/init.pp', line 52

class diamond(
    $handler       = 'diamond.handler.graphite.GraphiteHandler',
    $interval      = '60',
    $path_prefix   = 'servers',
    $keep_logs_for = '5',
    $service       = running,
    $settings      = {
        host  => 'localhost',
        port  => '8125',
        batch => '20',
    },
) {
    require_package('python-statsd')
    if empty($handler) {
        fail('$handler cannot be empty')
    }

    package { [ 'diamond', ]:
        ensure  => present,
    }

    file { [ '/etc/diamond/collectors', '/etc/diamond/handlers' ]:
        ensure  => directory,
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        recurse => true,
        purge   => true,
        force   => true,
        require => Package['diamond'],
    }

    file { '/etc/diamond/diamond.conf':
        content => template('diamond/diamond.conf.erb'),
        require => File['/etc/diamond/collectors', '/etc/diamond/handlers'],
    }

    # Truncate the import path, leaving only the class name.
    $handler_class = regsubst($handler, '.*\.', '')
    file { "/etc/diamond/handlers/${handler_class}.conf":
        content => template('diamond/handler.conf.erb'),
    }

    service { 'diamond':
        ensure     => $service,
        enable     => true,
        hasrestart => true,
        hasstatus  => true,
        require    => Package['diamond'],
        subscribe  => [
            File['/etc/diamond/diamond.conf'],
            File["/etc/diamond/handlers/${handler_class}.conf"],
        ],
    }

    systemd::unit { 'diamond':
        ensure   => present,
        restart  => true,
        override => true,
        content  => template('diamond/initscripts/diamond.systemd_override.erb'),
    }

    diamond::collector { 'CPU':
        settings => {
            # lint:ignore:quoted_booleans
            # As per comments above, these must be quoted for the config
            #  file.
            percore   => 'false',
            normalize => 'true',
            # lint:endignore
        },
    }

    diamond::collector { 'Network': }
    diamond::collector { 'DiskSpace':
        settings => {
            filesystems     => 'ext2,ext3,ext4,xfs,fuse.fuse_dfs,fat32,fat16,btrfs',
            # Dockerd has ephemeral mounts - T181295
            exclude_filters => [
                '^/var/lib/docker/',
                '^/run/docker/',
            ],
        },
    }

    diamond::collector { 'LoadAverage': }
    diamond::collector { 'Memory': }
    diamond::collector { 'VMStat': }


    diamond::collector { 'TCP':
        settings => {
            allowed_names => [
              'ListenOverflows', 'ListenDrops',
              'TCPLoss', 'TCPTimeouts',
              'TCPFastRetrans', 'TCPLostRetransmit',
              'TCPForwardRetrans', 'TCPSlowStartRetrans',
              'CurrEstab', 'TCPAbortOnMemory',
              'TCPBacklogDrop', 'AttemptFails',
              'EstabResets', 'InErrs',
              'ActiveOpens', 'PassiveOpens',
              'TCPFastOpenActive', 'TCPFastOpenActiveFail',
              'TCPFastOpenPassive', 'TCPFastOpenPassiveFail',
              'TCPFastOpenListenOverflow', 'TCPFastOpenCookieReqd',
              'TCPSynRetrans', 'TCPOrigDataSent',
            ],
            gauges        => [
              'CurrEstab', 'MaxConn',
              'TCPFastOpenActive', 'TCPFastOpenActiveFail',
              'TCPFastOpenPassive', 'TCPFastOpenPassiveFail',
              'TCPFastOpenListenOverflow', 'TCPFastOpenCookieReqd',
            ],
        },
    }

    diamond::collector { 'DiskUsage':
        settings => {
            devices => 'PhysicalDrive[0-9]+$|md[0-9]+$|sd[a-z]+$|x?vd[a-z]+$|disk[0-9]+$',
        },
    }
}