Puppet Class: mariadb::heartbeat

Defined in:
modules/mariadb/manifests/heartbeat.pp

Overview

mariadb heartbeat capability

Parameters:

  • enabled (Any) (defaults to: false)
  • interval (Any) (defaults to: 1)
  • shard (Any) (defaults to: 'unknown')
  • datacenter (Any) (defaults to: 'none')
  • socket (Any) (defaults to: '/run/mysqld/mysqld.sock')


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
# File 'modules/mariadb/manifests/heartbeat.pp', line 2

class mariadb::heartbeat (
    $enabled    = false,
    $interval   = 1,
    $shard      = 'unknown',
    $datacenter = 'none',
    $socket     = '/run/mysqld/mysqld.sock',
) {


    # custom modified version of pt-heartbeat that includes an
    # extra column "shard"
    file { '/usr/local/bin/pt-heartbeat-wikimedia':
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        source => 'puppet:///modules/mariadb/pt-heartbeat-wikimedia',
    }

    # TODO: This should be moved to systemd::service
    if $enabled {
        exec { 'pt-heartbeat':
            command => "/usr/bin/perl \
            /usr/local/bin/pt-heartbeat-wikimedia \
            --defaults-file=/dev/null \
            --user=root --host=localhost -D heartbeat \
            --shard=${shard} --datacenter=${datacenter} \
            --update --replace --interval=${interval} \
            --set-vars=\"binlog_format=${mariadb::config::binlog_format}\" \
            -S ${socket} --daemonize \
            --pid /var/run/pt-heartbeat.pid",
            unless  => '/bin/ps --pid $(cat /var/run/pt-heartbeat.pid) \
            > /dev/null 2>&1',
            user    => 'root',
            require => File['/usr/local/bin/pt-heartbeat-wikimedia'],
        }
    } else {
        exec { 'pt-heartbeat-kill':
            command => '/bin/kill -TERM $(cat /var/run/pt-heartbeat.pid)',
            onlyif  => '/bin/ps --pid $(cat /var/run/pt-heartbeat.pid) \
            > /dev/null 2>&1',
            user    => 'root',
        }
    }
}