Puppet Class: arclamp

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

Overview

Class: arclamp

Aggregate captured stack traces from MediaWiki application servers, write them to disk, and generate SVG flame graphs.

The aggregator reads captured traces from a Redis instance using pub/sub. MediaWiki servers capture these traces from Xenon, which is the built-in sampling profiler for HHVM.

Parameters

ensure

Description

redis_host

Address of Redis server that is publishing stack traces. Default: '127.0.0.1'.

redis_port

Port of Redis server that is publishing stack traces. Default: 6379.

Examples

class { 'arclamp':
    ensure     => present,
    redis_host => 'mwlog.example.net',
    redis_port => 6379,
}

Parameters:

  • ensure (Any) (defaults to: present)
  • redis_host (Any) (defaults to: '127.0.0.1')
  • redis_port (Any) (defaults to: 6379)


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
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
# File 'modules/arclamp/manifests/init.pp', line 31

class arclamp(
    $ensure = present,
    $redis_host = '127.0.0.1',
    $redis_port = 6379,
) {
    require_package('python-redis')
    require_package('python-yaml')

    $config = {
        base_path => '/srv/xenon/logs',
        redis     => {
            host => $redis_host,
            port => $redis_port,
        },
        logs      => [
            # 336 hours is 14 days * 24 hours (T166624)
            { period => 'hourly',  format => '%Y-%m-%d_%H', retain => 336 },
            { period => 'daily',   format => '%Y-%m-%d',    retain => 90 },
        ],
    }

    group { 'xenon':
        ensure => $ensure,
    }

    user { 'xenon':
        ensure     => $ensure,
        gid        => 'xenon',
        shell      => '/bin/false',
        home       => '/nonexistent',
        system     => true,
        managehome => false,
    }

    file { '/srv/xenon':
        ensure => ensure_directory($ensure),
        links  => 'follow',
        owner  => 'xenon',
        group  => 'xenon',
        mode   => '0755',
        before => Service['xenon-log'],
    }

    file { '/etc/xenon-log.yaml':
        ensure  => $ensure,
        content => ordered_yaml($config),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        notify  => Service['xenon-log'],
    }

    file { '/usr/local/bin/xenon-log':
        ensure => $ensure,
        source => 'puppet:///modules/arclamp/xenon-log',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        notify => Service['xenon-log'],
    }

    systemd::service { 'xenon-log':
        ensure  => $ensure,
        content => systemd_template('xenon-log'),
    }

    # This is the Perl script that generates flame graphs.
    # It comes from <https://github.com/brendangregg/FlameGraph>.

    file { '/usr/local/bin/flamegraph.pl':
        ensure => $ensure,
        source => 'puppet:///modules/arclamp/flamegraph.pl',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        notify => Service['xenon-log'],
    }


    # Walks /srv/xenon/logs looking for log files which do not have a
    # corresponding SVG file and calls flamegraph.pl on each of them.

    file { '/usr/local/bin/xenon-generate-svgs':
        ensure => $ensure,
        source => 'puppet:///modules/arclamp/xenon-generate-svgs',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
        before => Cron['xenon_generate_svgs'],
    }

    cron { 'xenon_generate_svgs':
        ensure  => $ensure,
        command => '/usr/local/bin/xenon-generate-svgs > /dev/null',
        user    => 'xenon',
        minute  => '*/15',
    }

    # xenon-grep is a simple CLI tool for parsing xenon logs
    # and printing a leaderboard of the functions which are most
    # frequently on-CPU.

    file { '/usr/local/bin/xenon-grep':
        ensure => $ensure,
        source => 'puppet:///modules/arclamp/xenon-grep',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }
}