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
|
# File 'modules/prometheus/manifests/node_exporter.pp', line 32
class prometheus::node_exporter (
String $ignored_fs_types = '^(overlay|autofs|binfmt_misc|cgroup|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|nsfs|proc|procfs|pstore|rpc_pipefs|securityfs|sysfs|tracefs)$',
String $ignored_mount_points = '^/(sys|proc|dev|var/lib/docker|var/lib/kubelet|run/credentials)($|/)',
String $netstat_fields = '^(.*)',
String $vmstat_fields = '^(.*)',
Array[String] $collectors_extra = [],
String $collector_ntp_server = '127.0.0.1',
Pattern[/:\d+$/] $web_listen_address = ':9100',
) {
$collectors_default = ['buddyinfo', 'conntrack', 'diskstats', 'entropy', 'edac', 'filefd', 'filesystem', 'hwmon',
'loadavg', 'mdadm', 'meminfo', 'netdev', 'netstat', 'sockstat', 'stat', 'tcpstat',
'textfile', 'time', 'uname', 'vmstat']
$textfile_directory = '/var/lib/prometheus/node.d'
$systemd_unit_exclude = '.+\\.(automount|device|mount|scope|slice|target|timer)'
package { 'prometheus-node-exporter':
ensure => 'present'
}
$collectors_enabled = concat($collectors_default, $collectors_extra)
if debian::codename::ge('bullseye') {
$collect_systemd_restart_count = true
} else {
$collect_systemd_restart_count = false
}
if debian::codename::eq('buster') {
file { '/etc/default/prometheus-node-exporter':
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => template('prometheus/etc/default/prometheus-node-exporter-0.17.erb'),
notify => Service['prometheus-node-exporter'],
}
} else {
file { '/etc/default/prometheus-node-exporter':
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => template('prometheus/etc/default/prometheus-node-exporter.erb'),
notify => Service['prometheus-node-exporter'],
}
}
# Up to 0.17 prometheus-node-exporter shipped a number of collectors in
# text_collector_examples, which were also shipped in the Debian package
# These were eventually moved to a separate repository (
# https://github.com/prometheus-community/node-exporter-textfile-collector-scripts)
# and got packaged as src:prometheus-node-exporter-collectors. Starting with
# 0.18.1+ds-2 (and thus Bullseye) prometheus-node-exporter declares a Recommends:
# on that package. But we don't install recommended packages by default and we don't
# need any of the shipped collectors, so restrict the disabling of the broken timers
# to distros up to Buster
if debian::codename::lt('bullseye') {
# Disabled because broken (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=922803)
service { 'prometheus-node-exporter-ipmitool-sensor.timer':
ensure => 'stopped',
provider => 'systemd',
enable => 'mask',
require => Package['prometheus-node-exporter'],
}
# Disabled in favor of internal smart module (smart-data-dump.py)
service { 'prometheus-node-exporter-smartmon.timer':
ensure => 'stopped',
provider => 'systemd',
enable => 'mask',
require => Package['prometheus-node-exporter'],
}
}
# members of this group are able to publish metrics
# via the 'textfile' collector by writing files to $textfile_directory.
# prometheus-node-exporter will export all files matching *.prom
group { 'prometheus-node-exporter':
ensure => present,
}
file { $textfile_directory:
ensure => directory,
mode => '0770',
owner => 'prometheus',
group => 'prometheus-node-exporter',
require => [Package['prometheus-node-exporter'],
Group['prometheus-node-exporter']],
}
base::service_unit { 'prometheus-node-exporter':
ensure => present,
refresh => true,
systemd_override => init_template('prometheus-node-exporter', 'systemd_override'),
require => Package['prometheus-node-exporter'],
}
profile::auto_restarts::service { 'prometheus-node-exporter': }
}
|