Puppet Class: monit::config
- Defined in:
- manifests/config.pp
Overview
monit::config This class handles the configuration files.
6 7 8 9 10 11 12 13 14 15 16 17 18 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'manifests/config.pp', line 6
class monit::config {
if $caller_module_name != $module_name {
warning("${name} is not part of the public API of the ${module_name} module and should not be directly included in the manifest.")
}
# Monit conf file and directory.
file { $monit::conf_file:
ensure => file,
mode => '0600',
content => template('monit/conf_file.erb'),
}
file { $monit::conf_dir:
ensure => directory,
recurse => true,
purge => $monit::conf_purge,
}
file { "${monit::conf_dir}/00_monit_config":
ensure => file,
content => template('monit/conf_file_overrides.erb'),
}
# System check
$tolerance = $monit::system_cycles ? {
undef => undef,
default => {
tolerance => {
cycles => $monit::system_cycles,
},
},
}
$system_tests_available = ['loadavg(1min)', 'loadavg(5min)', 'loadavg(15min)', 'cpu(user)', 'cpu(system)', 'cpu(wait)', 'memory', 'swap']
$system_tests = $system_tests_available.map |$test_type| {
# Convert loadavg(1min) to loadavg_1min
$param = regsubst(regsubst($test_type, '\)', ''), '\(', '_')
$value = getvar("monit::system_${param}")
if ($value) {
$test = {
'type' => $test_type,
'operator' => '>',
'value' => $value,
}
merge($test, $tolerance)
}
}.filter |$val| { $val =~ NotUndef }
# Filesystem checks
monit::check::system { $::facts['networking']['fqdn']:
ensure => $monit::system_check_ensure,
priority => '10',
group => 'system',
order => 0,
tests => $system_tests,
}
monit::check::filesystem { 'fs':
ensure => $monit::system_check_ensure,
priority => '10',
group => 'system',
bundle => $::facts['networking']['fqdn'],
order => 1,
paths => $monit::system_fs,
tests => [
{ 'type' => 'fsflags' },
{ 'type' => 'space', 'operator' => '>', 'value' => $monit::system_fs_space_usage },
{ 'type' => 'inode', 'operator' => '>', 'value' => $monit::system_fs_inode_usage },
],
}
# Network checks
$interfaces = $monit::system_ifaces ? {
undef => [$::facts['networking']['primary']],
default => $monit::system_ifaces,
}
$interfaces.each |$key| {
monit::check::network { "interface_${key}":
interface => $key,
bundle => 'network',
tests => [
{ 'type' => 'link' },
# TODO: check monit version >= 5.28.0
# { 'type' => 'link down' },
# { 'type' => 'link up' },
],
}
}
# Additional checks.
if ($monit::hiera_merge_strategy == 'hiera_hash') {
$mychecks = hiera_hash('monit::checks', {})
}
else {
$mychecks = $monit::checks
}
create_resources('monit::check', $mychecks)
}
|