From 513ed6ce7f339403de3662d91f6c7faa1e444852 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Sun, 1 Mar 2026 18:53:03 +0100 Subject: [PATCH] OP#436 add full service details --- manifests/client/target.pp | 196 ++++++++++++++++++------------------- manifests/params.pp | 3 + 2 files changed, 101 insertions(+), 98 deletions(-) diff --git a/manifests/client/target.pp b/manifests/client/target.pp index 7a3dbfb..35d4bf6 100644 --- a/manifests/client/target.pp +++ b/manifests/client/target.pp @@ -6,112 +6,52 @@ class confdroid_nagios::client::target ( ) inherits confdroid_nagios::params { - if $ng_nagios_server == $fqdn { + if ($ng_nagios_server == $fqdn) and ($ng_enable_target == true) { if $ng_include_nrpe == true { require confdroid_nrpe + } - @@nagios_host { $fqdn: - ensure => $ng_ping_ensure, - alias => $hostname, - address => $fqdn, - use => 'linux-server', - target => $ng_target_host, - hostgroups => 'linux-servers', - contacts => $ng_contact_name, - max_check_attempts => $ng_max_check_attempts, - notification_period => '24x7', - owner => 'nagios', - group => 'nagios', - mode => '0640', - check_command => "check_ping!${ng_ping_warn}!${ng_ping_crit}", - notify => Service[$ng_service], - } + @@nagios_host { $fqdn: + ensure => $ng_ping_ensure, + alias => $hostname, + address => $fqdn, + use => 'linux-server', + target => $ng_target_host, + hostgroups => 'linux-servers', + contacts => $ng_contact_name, + max_check_attempts => $ng_max_check_attempts, + notification_period => '24x7', + owner => 'nagios', + group => 'nagios', + mode => '0640', + check_command => "check_ping!${ng_ping_warn}!${ng_ping_crit}", + notify => Service[$ng_service], + } - @@nagios_service { "root_partition_${fqdn}": - ensure => $ng_disk_ensure, - check_command => "check_nrpe!check_disk!${ng_disk_warn}!${ng_disk_crit}!/", + @@nagios_service { "root_partition_${fqdn}": + ensure => $ng_disk_ensure, + check_command => "check_nrpe!check_disk!${ng_disk_warn}!${ng_disk_crit}!/", + use => 'generic-service', + host_name => $fqdn, + contacts => $ng_contact_name, + notification_period => '24x7', + service_description => "${fqdn}_root_partition", + servicegroups => 'linux-services', + target => $ng_target_service, + owner => 'nagios', + group => 'nagios', + mode => '0640', + } + + if $ng_enable_swap_check == true { + @@nagios_service { "Swap_Usage_${fqdn}": + ensure => $ng_swap_ensure, + check_command => "check_nrpe!check_swap!${ng_swap_warn}!${ng_swap_crit}", use => 'generic-service', host_name => $fqdn, contacts => $ng_contact_name, notification_period => '24x7', - service_description => "${fqdn}_root_partition", - servicegroups => 'linux-services', - target => $ng_target_service, - owner => 'nagios', - group => 'nagios', - mode => '0640', - } - - if $ng_enable_swap_check == true { - @@nagios_service { "Swap_Usage_${fqdn}": - ensure => $ng_swap_ensure, - check_command => "check_nrpe!check_swap!${ng_swap_warn}!${ng_swap_crit}", - use => 'generic-service', - host_name => $fqdn, - contacts => $ng_contact_name, - notification_period => '24x7', - service_description => "${fqdn}_swap_usage", - servicegroups => 'linux-services', - target => $ng_target_service, - owner => 'nagios', - group => 'nagios', - mode => '0640', - } - } - - @@nagios_service { "Local_Users_${fqdn}": - ensure => $ng_users_ensure, - check_command => "check_nrpe!check_users!${ng_users_warn}!${ng_users_crit}", - use => 'generic-service', - host_name => $fqdn, - contacts => $ng_contact_name, - notification_period => '24x7', - service_description => "${fqdn}_local_users", - servicegroups => 'linux-services', - target => $ng_target_service, - owner => 'nagios', - group => 'nagios', - mode => '0640', - } - - @@nagios_service { "Total Processes_${fqdn}": - ensure => $ng_procs_tot_ens, - check_command => "check_nrpe!check_procs!${ng_procs_tot_warn}!${ng_procs_tot_crit}!${ng_procs_tot_param}", - use => 'generic-service', - host_name => $fqdn, - contacts => $ng_contact_name, - notification_period => '24x7', - service_description => "${fqdn}_total_processes", - servicegroups => 'linux-services', - target => $ng_target_service, - owner => 'nagios', - group => 'nagios', - mode => '0640', - } - - @@nagios_service { "Zombie Processes_${fqdn}": - ensure => $ng_procs_z_ensure, - check_command => "check_nrpe!check_procs!${ng_procs_z_warn}!${ng_procs_z_crit}!${ng_procs_z_param}", - use => 'generic-service', - host_name => $fqdn, - contacts => $ng_contact_name, - notification_period => '24x7', - service_description => "${fqdn}_zombie_processes", - servicegroups => 'linux-services', - target => $ng_target_service, - owner => 'nagios', - group => 'nagios', - mode => '0640', - } - - @@nagios_service { "Current_Load_${fqdn}": - ensure => $ng_load_ensure, - check_command => "check_nrpe!check_load!${ng_load_warn}!${ng_load_crit}", - use => 'generic-service', - host_name => $fqdn, - contacts => $ng_contact_name, - notification_period => '24x7', - service_description => "${fqdn}_current_load", + service_description => "${fqdn}_swap_usage", servicegroups => 'linux-services', target => $ng_target_service, owner => 'nagios', @@ -119,5 +59,65 @@ class confdroid_nagios::client::target ( mode => '0640', } } + + @@nagios_service { "Local_Users_${fqdn}": + ensure => $ng_users_ensure, + check_command => "check_nrpe!check_users!${ng_users_warn}!${ng_users_crit}", + use => 'generic-service', + host_name => $fqdn, + contacts => $ng_contact_name, + notification_period => '24x7', + service_description => "${fqdn}_local_users", + servicegroups => 'linux-services', + target => $ng_target_service, + owner => 'nagios', + group => 'nagios', + mode => '0640', + } + + @@nagios_service { "Total Processes_${fqdn}": + ensure => $ng_procs_tot_ens, + check_command => "check_nrpe!check_procs!${ng_procs_tot_warn}!${ng_procs_tot_crit}!${ng_procs_tot_param}", + use => 'generic-service', + host_name => $fqdn, + contacts => $ng_contact_name, + notification_period => '24x7', + service_description => "${fqdn}_total_processes", + servicegroups => 'linux-services', + target => $ng_target_service, + owner => 'nagios', + group => 'nagios', + mode => '0640', + } + + @@nagios_service { "Zombie Processes_${fqdn}": + ensure => $ng_procs_z_ensure, + check_command => "check_nrpe!check_procs!${ng_procs_z_warn}!${ng_procs_z_crit}!${ng_procs_z_param}", + use => 'generic-service', + host_name => $fqdn, + contacts => $ng_contact_name, + notification_period => '24x7', + service_description => "${fqdn}_zombie_processes", + servicegroups => 'linux-services', + target => $ng_target_service, + owner => 'nagios', + group => 'nagios', + mode => '0640', + } + + @@nagios_service { "Current_Load_${fqdn}": + ensure => $ng_load_ensure, + check_command => "check_nrpe!check_load!${ng_load_warn}!${ng_load_crit}", + use => 'generic-service', + host_name => $fqdn, + contacts => $ng_contact_name, + notification_period => '24x7', + service_description => "${fqdn}_current_load", + servicegroups => 'linux-services', + target => $ng_target_service, + owner => 'nagios', + group => 'nagios', + mode => '0640', + } } } diff --git a/manifests/params.pp b/manifests/params.pp index dd1e6c1..4636cff 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -99,6 +99,8 @@ # to be submitted to Nagios. Default is '1'. # @param [String] ng_user The user to run the Nagios service as. # Default is 'nagios'. +# @param [Boolean] ng_enable_target Whether to enable the generation of host and +# service configuration files for the Nagios server. Default is true. ############################################################################### class confdroid_nagios::params ( @@ -114,6 +116,7 @@ class confdroid_nagios::params ( String $ng_status_upd_interval = '10', String $ng_check_ext_commands = '1', String $ng_user = 'nagios', + Boolean $ng_enable_target = true, # contact groups String $ng_contactgroup_name = 'admins',