From 26ea8e8e8d29cb37790d224592378bd517f5a5ce Mon Sep 17 00:00:00 2001 From: Rikard Danielsson Date: Thu, 13 Mar 2025 12:15:34 +0100 Subject: [PATCH] first attempt at creating extra_host_groups --- manifests/sitemonitornaemon.pp | 9 +++++++++ templates/monitor/sunetdrive_extra_hostgroups.cfg.erb | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 templates/monitor/sunetdrive_extra_hostgroups.cfg.erb diff --git a/manifests/sitemonitornaemon.pp b/manifests/sitemonitornaemon.pp index 55fc404..cf0b62d 100644 --- a/manifests/sitemonitornaemon.pp +++ b/manifests/sitemonitornaemon.pp @@ -11,6 +11,9 @@ class sunetdrive::sitemonitornaemon() { $environment = sunetdrive::get_environment() $influx_passwd = safe_hiera('influx_passwd') $slack_url = safe_hiera('slack_url') + $extra_host_groups = { + node3_hosts => join($facts['configured_hosts_in_cosmos']['all'].filter |$host| { $host =~ /^node3\./ }, ',') + } file { '/usr/local/bin/slack_nagios.sh': ensure => present, @@ -45,6 +48,11 @@ class sunetdrive::sitemonitornaemon() { content => template('sunetdrive/monitor/sunetdrive_thruk_templates.conf.erb'), mode => '0644', } + file { '/etc/naemon/conf.d/sunetdrive_extra_hostgroups.cfg': + ensure => present, + content => template('sunetdrive/monitor/sunetdrive_extra_hostgroups.cfg.erb'), + mode => '0644', + } nagioscfg::service {'check_scriptherder': hostgroup_name => ['sunetdrive::nrpe'], check_command => 'check_nrpe_1arg_to300!check_scriptherder', @@ -105,5 +113,6 @@ class sunetdrive::sitemonitornaemon() { description => 'S3 buckets with multiple Nextcloud mounts', contact_groups => ['alerts'] } + } diff --git a/templates/monitor/sunetdrive_extra_hostgroups.cfg.erb b/templates/monitor/sunetdrive_extra_hostgroups.cfg.erb new file mode 100644 index 0000000..246bc21 --- /dev/null +++ b/templates/monitor/sunetdrive_extra_hostgroups.cfg.erb @@ -0,0 +1,8 @@ +<% @extra_host_groups.each do |group, members| -%> +# <%= group -%> +define hostgroup { + hostgroup_name <%= group -%> + alias <%= group -%> + members <%= members -%> +} +<% end -%>