diff --git a/site-modules/profile/manifests/icinga2/objects/agent_checks.pp b/site-modules/profile/manifests/icinga2/objects/agent_checks.pp index af4e2d9e..34fcea8c 100644 --- a/site-modules/profile/manifests/icinga2/objects/agent_checks.pp +++ b/site-modules/profile/manifests/icinga2/objects/agent_checks.pp @@ -1,110 +1,110 @@ # Checks that need to be supported on icinga2 agents class profile::icinga2::objects::agent_checks { $plugins = { 'check_journal' => { arguments => { '-f' => { 'value' => '$journal_cursor_file$', - 'set_if' => '$journal_cursor_file$', + 'set_if' => '{{ var filename = macro("$journal_cursor_file$"); return len(filename) > 0 }}', }, '-w' => '$journal_lag_warn$', '-c' => '$journal_lag_crit$', '-wn' => { 'value' => '$journal_lag_entries_warn$', 'set_if' => '$journal_lag_entries_warn$', }, '-cn' => { 'value' => '$journal_lag_entries_crit$', 'set_if' => '$journal_lag_entries_crit$', }, }, vars => { 'journal_lag_warn' => 1200, 'journal_lag_crit' => 3600, }, sudo => true, sudo_user => 'journalbeat', }, 'check_newest_file_age' => { arguments => { '-d' => '$check_directory$', '-w' => '$check_directory_warn_age$', '-c' => '$check_directory_crit_age$', '-W' => { 'set_if' => '$check_directory_missing_warn$', }, '-C' => { 'set_if' => '$check_directory_missing_crit$', }, }, vars => { 'check_directory_warn_age' => 26, 'check_directory_crit_age' => 52, 'check_directory_missing_warn' => false, 'check_directory_missing_crit' => true, }, sudo => true, sudo_user => 'root', }, } $swh_plugin_dir = '/usr/lib/nagios/plugins/swh' $swh_plugin_configfile = '/etc/icinga2/conf.d/swh-plugins.conf' $packages = [ 'python3-nagiosplugin', 'python3-systemd', 'monitoring-plugins-basic', ] package {$packages: ensure => present, } file {$swh_plugin_dir: ensure => 'directory', owner => 'root', group => 'root', mode => '0755', recurse => true, purge => true, require => Package[$packages], } $plugins.each |$command, $plugin| { $command_path = "${swh_plugin_dir}/${command}" file {$command_path: ensure => present, owner => 'root', group => 'root', mode => '0755', source => "puppet:///modules/profile/icinga2/plugins/${command}", require => Package[$packages], } if $plugin['sudo'] { $sudo_user = $plugin['sudo_user'] $icinga_command = ['sudo', '-u', $sudo_user, $command_path] ::sudo::conf { "icinga-${command}": ensure => present, content => "nagios ALL=(${sudo_user}) NOPASSWD: ${command_path}", priority => 50, } } else { $icinga_command = [$command_path] ::sudo::conf { "icinga-${command}": ensure => absent, } } ::icinga2::object::checkcommand {$command: import => ['plugin-check-command'], command => $icinga_command, arguments => $plugin['arguments'], vars => $plugin['vars'], target => $swh_plugin_configfile, } } } diff --git a/site-modules/profile/manifests/icinga2/plugins/rabbitmq.pp b/site-modules/profile/manifests/icinga2/plugins/rabbitmq.pp index c1231deb..7a6804c1 100644 --- a/site-modules/profile/manifests/icinga2/plugins/rabbitmq.pp +++ b/site-modules/profile/manifests/icinga2/plugins/rabbitmq.pp @@ -1,89 +1,89 @@ # RabbitMQ icinga2 plugins class profile::icinga2::plugins::rabbitmq { $packages = ['nagios-plugins-rabbitmq', 'libjson-perl'] package {$packages: ensure => present, } $plugin_configfile = '/etc/icinga2/conf.d/rabbitmq-plugins.conf' $base_arguments = { '-H' => '$rabbitmq_host$', '--port' => '$rabbitmq_port$', '--user' => '$rabbitmq_user$', '--password' => '$rabbitmq_password$', '--vhost' => { 'value' => '$rabbitmq_vhost$', - 'set_if' => '$rabbitmq_vhost$', + 'set_if' => '{{ var vhost = macro("$rabbitmq_vhost$"); return len(vhost) > 0 }}', } } $base_vars = { 'rabbitmq_host' => '$check_address$', 'rabbitmq_port' => '15672', 'rabbitmq_user' => 'guest', 'rabbitmq_password' => 'guest', } $plugins = { rabbitmq_shovels => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_partition => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_connections => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_aliveness => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_cluster => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_watermark => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_server => { arguments => $base_arguments + { '--node' => '$rabbitmq_node$', }, vars => $base_vars + { 'rabbitmq_node' => '$check_address$', }, }, rabbitmq_exchange => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_objects => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_overview => { arguments => $base_arguments, vars => $base_vars, }, rabbitmq_queue => { arguments => $base_arguments, vars => $base_vars, }, } $plugins.each |$command, $plugin| { ::icinga2::object::checkcommand {$command: import => ['plugin-check-command', 'ipv4-or-ipv6'], command => ["-:PluginContribDir + \"-rabbitmq/check_${command}\""], arguments => $plugin['arguments'], vars => $plugin['vars'], target => $plugin_configfile, } } }