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
|
# File 'modules/prometheus/manifests/mysqld_exporter/instance.pp', line 22
define prometheus::mysqld_exporter::instance (
Stdlib::Unixpath $client_socket = '/run/mysqld/mysqld.sock',
String $client_user = 'prometheus',
String $client_password = 'This is a fake passsword, but cannot be empty due to Debian #953040',
String $listen_address = ':9104',
) {
# TODO: split listen address params
# Stdlib::IP:Address $listen_ip
# Stdlib::Port $listen_Port
# $listen_address = "${listen_ip}:${listen_port}"
include prometheus::mysqld_exporter::common
$my_cnf = "/var/lib/prometheus/.my.${title}.cnf"
$service = "prometheus-mysqld-exporter@${title}"
$common_options = [
"web.listen-address \"${listen_address}\"",
"config.my-cnf \"${my_cnf}\"",
'collect.global_status',
'collect.global_variables',
'collect.info_schema.processlist',
'collect.slave_status',
]
$option_switch = '--'
$version_specific_options = ['no-collect.info_schema.tables']
#We only want to restart if the service is running
#(which it won't be if the relevant mariadb isn't)
exec { "systemctl try-restart ${service}":
refreshonly => true,
path => '/usr/bin',
}
$options_str = ($common_options + $version_specific_options).reduce('') |$memo, $value| {
"${memo} ${option_switch}${value}"
}.strip
file { "/etc/default/prometheus-mysqld-exporter@${title}":
ensure => present,
mode => '0444',
owner => 'root',
group => 'root',
content => "ARGS='${options_str}'",
notify => Exec["systemctl try-restart ${service}"],
}
# a separate database config (.my.<instance_name>cnf) for each instance monitored
# change the systemd unit if the patch changes here, as it depends on it
file { $my_cnf:
ensure => present,
mode => '0400',
owner => 'prometheus',
group => 'prometheus',
content => template('prometheus/mysqld_exporter.cnf.erb'),
notify => Exec["systemctl try-restart ${service}"],
}
profile::auto_restarts::service { $service: }
}
|