Puppet Class: profile::monitoring

Defined in:
modules/profile/manifests/monitoring.pp

Overview

Parameters:

  • hardware_monitoring (Wmflib::Ensure) (defaults to: lookup('profile::monitoring::hardware_monitoring'))

    indicate if we should monitor HW

  • contact_group (String) (defaults to: lookup('profile::monitoring::contact_group'))

    Nagios contact_group to use for notifications.

  • mgmt_contact_group (String) (defaults to: lookup('profile::monitoring::mgmt_contact_group'))

    Nagios contact_group to use for notifications related to the drac/ilo interface.

  • notifications_enabled (Boolean) (defaults to: lookup('profile::monitoring::notifications_enabled'))

    inticate if we should send notifications

  • is_critical (Boolean) (defaults to: lookup('profile::monitoring::is_critical'))

    indicate this host is critical

  • monitor_systemd (Boolean) (defaults to: lookup('profile::monitoring::monitor_systemd'))

    indicate if we should monitor systemd

  • monitor_screens

    indicate if we should monitor screens

  • puppet_interval

    interval for puppet checks

  • nrpe_check_disk_options (String) (defaults to: lookup('profile::monitoring::nrpe_check_disk_options'))

    Default options for checking disks. Defaults to checking all disks and warning at < 6% and critical at < 3% free.

  • check_raid

    indicate if we should check raid

  • nrpe_check_disk_critical (Boolean) (defaults to: lookup('profile::monitoring::nrpe_check_disk_critical'))

    Make disk space alerts paging, defaults to not paging

  • cluster (String) (defaults to: lookup('profile::monitoring::cluster'))
  • check_smart (Boolean) (defaults to: lookup('profile::monitoring::check_smart'))
  • raid_check (Boolean) (defaults to: lookup('profile::monitoring::raid_check'))
  • raid_check_interval (Integer) (defaults to: lookup('profile::monitoring::raid_check_interval'))
  • raid_retry_interval (Integer) (defaults to: lookup('profile::monitoring::raid_retry_interval'))
  • do_paging (Boolean) (defaults to: lookup('profile::monitoring::do_paging'))
  • nagios_group (String) (defaults to: lookup('profile::monitoring::nagios_group'))
  • mgmt_parents (Hash) (defaults to: lookup('profile::monitoring::mgmt_parents'))
  • services (Hash) (defaults to: lookup('profile::monitoring::services'))
  • hosts (Hash) (defaults to: lookup('profile::monitoring::hosts'))
  • monitoring_hosts (Array[Stdlib::Host]) (defaults to: lookup('profile::monitoring::monitoring_hosts'))
  • raid_write_cache_policy (Optional[Enum['WriteThrough', 'WriteBack']]) (defaults to: lookup('profile::monitoring::raid_write_cache_policy'))


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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'modules/profile/manifests/monitoring.pp', line 30

class profile::monitoring(
    Wmflib::Ensure      $hardware_monitoring        = lookup('profile::monitoring::hardware_monitoring'),
    # TODO: make this an array
    String              $contact_group              = lookup('profile::monitoring::contact_group'),
    String              $mgmt_contact_group         = lookup('profile::monitoring::mgmt_contact_group'),
    String              $cluster                    = lookup('profile::monitoring::cluster'),
    Boolean             $is_critical                = lookup('profile::monitoring::is_critical'),
    Boolean             $monitor_systemd            = lookup('profile::monitoring::monitor_systemd'),
    String              $nrpe_check_disk_options    = lookup('profile::monitoring::nrpe_check_disk_options'),
    Boolean             $nrpe_check_disk_critical   = lookup('profile::monitoring::nrpe_check_disk_critical'),
    Boolean             $check_smart                = lookup('profile::monitoring::check_smart'),
    Boolean             $raid_check                 = lookup('profile::monitoring::raid_check'),
    Integer             $raid_check_interval        = lookup('profile::monitoring::raid_check_interval'),
    Integer             $raid_retry_interval        = lookup('profile::monitoring::raid_retry_interval'),
    Boolean             $notifications_enabled      = lookup('profile::monitoring::notifications_enabled'),
    Boolean             $do_paging                  = lookup('profile::monitoring::do_paging'),
    String              $nagios_group               = lookup('profile::monitoring::nagios_group'),
    Hash                $mgmt_parents               = lookup('profile::monitoring::mgmt_parents'),
    Hash                $services                   = lookup('profile::monitoring::services'),
    Hash                $hosts                      = lookup('profile::monitoring::hosts'),
    Array[Stdlib::Host] $monitoring_hosts           = lookup('profile::monitoring::monitoring_hosts'),
    Optional[Enum['WriteThrough', 'WriteBack']] $raid_write_cache_policy = lookup('profile::monitoring::raid_write_cache_policy')
) {
    ensure_packages('ruby-safe-yaml')

    include profile::base::puppet
    $puppet_interval = $profile::base::puppet::interval

    if $raid_check and $hardware_monitoring == 'present'{
        # RAID checks
        class { 'raid':
            write_cache_policy => $raid_write_cache_policy,
            check_interval     => $raid_check_interval,
            retry_interval     => $raid_retry_interval,
        }
    }

    class { 'monitoring':
        contact_group         => $contact_group,
        mgmt_contact_group    => $mgmt_contact_group,
        nagios_group          => $nagios_group,
        cluster               => $cluster,
        notifications_enabled => $notifications_enabled,
        do_paging             => $do_paging,
        mgmt_parents          => $mgmt_parents,
        hosts                 => $hosts,
        services              => $services,
    }


    sudo::user { 'nagios_puppetrun':
        user       => 'nagios',
        privileges => ['ALL = NOPASSWD: /usr/local/lib/nagios/plugins/check_puppetrun'],
    }

    class { 'nrpe':
        allowed_hosts => $monitoring_hosts.join(','),
    }
    # the nrpe class installs monitoring-plugins-* which creates the following directory
    contain nrpe  # lint:ignore:wmf_styleguide
    file {
        default:
            ensure => present,
            owner  => 'root',
            group  => 'root',
            mode   => '0555';
        '/usr/local/lib/nagios/plugins/check_puppetrun':
            source => 'puppet:///modules/base/monitoring/check_puppetrun.rb';
        '/usr/local/lib/nagios/plugins/check_eth':
            content => template('base/check_eth.erb');
        '/usr/lib/nagios/plugins/check_sysctl':
            source => 'puppet:///modules/base/check_sysctl';
        '/usr/lib/nagios/plugins/check_established_connections':
            source => 'puppet:///modules/base/monitoring/check_established_connections.sh';
        '/usr/lib/nagios/plugins/check-fresh-files-in-dir.py':
            source => 'puppet:///modules/base/monitoring/check-fresh-files-in-dir.py';
    }

    nrpe::monitor_service { 'disk_space':
        description     => 'Disk space',
        critical        => $nrpe_check_disk_critical,
        nrpe_command    => "/usr/lib/nagios/plugins/check_disk ${nrpe_check_disk_options}",
        notes_url       => 'https://wikitech.wikimedia.org/wiki/Monitoring/Disk_space',
        dashboard_links => ["https://grafana.wikimedia.org/dashboard/db/host-overview?var-server=${facts['hostname']}&var-datasource=${::site} prometheus/ops"],
        check_interval  => 20,
        retry_interval  => 5,
    }

    nrpe::monitor_service { 'dpkg':
        description    => 'DPKG',
        nrpe_command   => '/usr/local/lib/nagios/plugins/check_dpkg',
        notes_url      => 'https://wikitech.wikimedia.org/wiki/Monitoring/dpkg',
        check_interval => 30,
    }

    # Calculate freshness interval in seconds (hence *60)
    $warninginterval = $puppet_interval * 60 * 6
    $criticalinterval = $warninginterval * 2

    nrpe::monitor_service { 'puppet_checkpuppetrun':
        description    => 'puppet last run',
        nrpe_command   => "/usr/bin/sudo /usr/local/lib/nagios/plugins/check_puppetrun -w ${warninginterval} -c ${criticalinterval}",
        check_interval => 5,
        retry_interval => 1,
        notes_url      => 'https://wikitech.wikimedia.org/wiki/Monitoring/puppet_checkpuppetrun',
    }
    nrpe::monitor_service {'check_eth':
        description    => 'configured eth',
        nrpe_command   => '/usr/local/lib/nagios/plugins/check_eth',
        notes_url      => 'https://wikitech.wikimedia.org/wiki/Monitoring/check_eth',
        check_interval => 30,
    }
    nrpe::monitor_service { 'check_dhclient':
        description    => 'dhclient process',
        nrpe_command   => '/usr/lib/nagios/plugins/check_procs -w 0:0 -c 0:0 -C dhclient',
        notes_url      => 'https://wikitech.wikimedia.org/wiki/Monitoring/check_dhclient',
        check_interval => 30,
    }

    $ensure_monitor_systemd = $monitor_systemd.bool2str('present','absent')

    file { '/usr/local/lib/nagios/plugins/check_systemd_state':
        ensure => $ensure_monitor_systemd,
        source => 'puppet:///modules/base/check_systemd_state.py',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    nrpe::monitor_service { 'check_systemd_state':
        ensure       => $ensure_monitor_systemd,
        description  => 'Check systemd state',
        nrpe_command => '/usr/local/lib/nagios/plugins/check_systemd_state',
        notes_url    => 'https://wikitech.wikimedia.org/wiki/Monitoring/check_systemd_state',
    }

    if $facts['productname'] == 'PowerEdge R320' {

        file { '/usr/local/lib/nagios/plugins/check_cpufreq':
            ensure => present,
            source => 'puppet:///modules/base/monitoring/check_cpufreq',
            owner  => 'root',
            group  => 'root',
            mode   => '0555',
        }

        nrpe::monitor_service { 'check_cpufreq':
            description  => 'CPU frequency',
            nrpe_command => '/usr/local/lib/nagios/plugins/check_cpufreq 600',
            notes_url    => 'https://wikitech.wikimedia.org/wiki/Monitoring/check_cpufreq',
        }
    }


    if ! $facts['is_virtual'] {
        monitoring::check_prometheus { 'smart_healthy':
            ensure          => $hardware_monitoring,
            description     => 'Device not healthy (SMART)',
            dashboard_links => ["https://grafana.wikimedia.org/dashboard/db/host-overview?var-server=${facts['hostname']}&var-datasource=${::site} prometheus/ops"],
            contact_group   => $contact_group,
            query           => "device_smart_healthy{instance=\"${facts['hostname']}:9100\"}",
            method          => 'le',
            warning         => 0,
            critical        => 0,
            check_interval  => 30,
            retry_interval  => 5,
            retries         => 3,
            prometheus_url  => "http://prometheus.svc.${::site}.wmnet/ops",
            notes_link      => 'https://wikitech.wikimedia.org/wiki/SMART#Alerts',
        }
        include profile::prometheus::nic_saturation_exporter
        class { 'prometheus::node_nic_firmware': }
        if $check_smart {
            class { '::smart': }
        }
        if $::processor0 !~ /AMD/ {
            class { 'prometheus::node_intel_microcode': }
        }
    }

    # Did an host register an increase in correctable errors over the last 4d? Might indicate faulty
    # memory
    monitoring::check_prometheus { 'edac_correctable_errors':
        ensure          => $hardware_monitoring,
        description     => 'Memory correctable errors (EDAC)',
        dashboard_links => ["https://grafana.wikimedia.org/dashboard/db/host-overview?orgId=1&var-server=${facts['hostname']}&var-datasource=${::site} prometheus/ops"],
        contact_group   => $contact_group,
        query           => "sum(increase(node_edac_correctable_errors_total{instance=\"${facts['hostname']}:9100\"}[4d]))",
        warning         => 2,
        critical        => 4,
        check_interval  => 30,
        retry_interval  => 5,
        retries         => 3,
        method          => 'ge',
        prometheus_url  => "http://prometheus.svc.${::site}.wmnet/ops",
        notes_link      => 'https://wikitech.wikimedia.org/wiki/Monitoring/Memory#Memory_correctable_errors_-EDAC-',
    }

    # Did an host log kernel messages from the EDAC subsystem over the last 4d? Might indicate faulty
    # memory.
    # Some of these events are not being caught through the usual node_edac_correctable_errors mechanism:
    # https://phabricator.wikimedia.org/T214529
    monitoring::check_prometheus { 'edac_syslog_events':
        ensure          => $hardware_monitoring,
        description     => 'EDAC syslog messages',
        dashboard_links => ["https://grafana.wikimedia.org/dashboard/db/host-overview?orgId=1&var-server=${facts['hostname']}&var-datasource=${::site} prometheus/ops"],
        contact_group   => $contact_group,
        query           => "sum(increase(edac_events{hostname=\"${facts['hostname']}\"}[4d]))",
        warning         => 2,
        critical        => 4,
        check_interval  => 30,
        retry_interval  => 5,
        retries         => 3,
        method          => 'ge',
        prometheus_url  => "http://prometheus.svc.${::site}.wmnet/ops",
        notes_link      => 'https://wikitech.wikimedia.org/wiki/Monitoring/Memory#Memory_correctable_errors_-EDAC-'
    }

    # Alert on reported fs available being bigger than fs size
    # Ideally this would be in check_disk instead, see also https://phabricator.wikimedia.org/T199436
    monitoring::check_prometheus { 'filesystem_avail_bigger_than_size':
        description     => 'Filesystem available is greater than filesystem size',
        dashboard_links => ["https://grafana.wikimedia.org/dashboard/db/host-overview?orgId=1&var-server=${facts['hostname']}&var-datasource=${::site} prometheus/ops"],
        contact_group   => $contact_group,
        query           => "node_filesystem_avail_bytes{instance=\"${facts['hostname']}:9100\"} > node_filesystem_size_bytes",
        # The query returns node_filesystem_avail_bytes metrics that match the condition. warning/critical
        # are required but placeholders in this case.
        warning         => 1,
        critical        => 2,
        check_interval  => 60,
        retry_interval  => 5,
        retries         => 3,
        method          => 'ge',
        prometheus_url  => "http://prometheus.svc.${::site}.wmnet/ops",
        notes_link      => 'https://phabricator.wikimedia.org/T199436',
    }
    if $facts['has_ipmi'] {
        class { 'ipmi::monitor': ensure => $hardware_monitoring }
    }
    # This is responsible for ~75%+ of all recdns queries...
    # https://phabricator.wikimedia.org/T239862
    host { 'statsd.eqiad.wmnet':
        ip           => '10.64.16.149', # graphite1004
        host_aliases => 'statsd',
    }
}