Puppet Class: nrpe

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

Overview

Class: nrpe

This installes nrpe packages, ensures service is running and collects all configuration

Parameters:

Actions:

Install nrpe packages
Manage nrpe service status
Collect all needed exported resources

Requires:

Definition[monitor_service]

Sample Usage:

include ::nrpe

Parameters:

  • allowed_hosts (Any) (defaults to: '127.0.0.1')


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
76
77
78
79
80
81
# File 'modules/nrpe/manifests/init.pp', line 19

class nrpe($allowed_hosts='127.0.0.1') {
    package { [ 'nagios-nrpe-server',
                'monitoring-plugins',
                'monitoring-plugins-basic',
                'monitoring-plugins-standard',
            ]:
        ensure => present,
    }

    $nrpe_local_data = {
        server_address => $facts['wmflib']['is_container'] ? {
            true  => '0.0.0.0',
            false => $facts['networking']['ip'],
        },
        allowed_hosts  => $allowed_hosts,
    }
    file { '/etc/nagios/nrpe_local.cfg':
        ensure  => present,
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => epp('nrpe/nrpe_local.cfg.epp', $nrpe_local_data),
        require => Package['nagios-nrpe-server'],
        notify  => Service['nagios-nrpe-server'],
    }

    file { '/usr/local/lib/nagios/':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
    }

    # Have a directory with all our plugins.
    file { '/usr/local/lib/nagios/plugins/':
        ensure  => directory,
        owner   => 'root',
        group   => 'root',
        mode    => '0555',
        recurse => true,
        purge   => true,
        force   => true,
        require => File['/usr/local/lib/nagios/'],
    }

    base::service_unit { 'nagios-nrpe-server':
        systemd => systemd_template('nagios-nrpe-server'),
        require => Package['nagios-nrpe-server'],
    }

    profile::auto_restarts::service { 'nagios-nrpe-server': }

    #Collect virtual nrpe checks
    File <| tag == 'nrpe::check' |> {
        require => Package['nagios-nrpe-server'],
    }

    Sudo::User <| tag == 'nrpe::check' |>

    File <| tag == 'nrpe::plugin' |> {
        require => File['/usr/local/lib/nagios/plugins/'],
    }
}