From 6c153ba938affe673f11dd9ac5e863ac96220b35 Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Sat, 7 Mar 2026 12:06:20 +0100 Subject: [PATCH] OP#436 more controls --- manifests/params.pp | 95 +++++++++++---- templates/nagios/nagios_cfg.erb | 197 ++++---------------------------- 2 files changed, 96 insertions(+), 196 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index 0d21c3a..0432a91 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -117,23 +117,57 @@ # Default is '1'. # @param [String] ng_log_notifications Whether to log notifications in Nagios. # Default is '1'. +# @param [String] ng_log_service_retries Whether to log service check retries +# in Nagios. Default is '1'. +# @param [String] ng_log_host_retries Whether to log host check retries +# in Nagios. Default is '1'. +# @param [String] ng_log_event_handlers Whether to log event handlers in Nagios. +# Default is '1'. +# @param [String] ng_log_initial_states Whether to log initial states in Nagios. +# Default is '0'. +# @param [String] ng_log_current_states Whether to log current states in Nagios. +# Default is '1'. +# @param [String] ng_log_external_commands Whether to log external commands in +# Nagios. Default is '1'. +# @param [String] ng_log_passive_checks Whether to log passive checks in Nagios. +# Default is '1'. +# @param [Array] ng_glob_host_evt_handler An array of global host event handlers +# for Nagios. Default is []. +# @param [Array] ng_glob_svc_evt_handler An array of global service event handlers +# for Nagios. Default is []. +# @param [String] ng_svc_int_check_delay The service inter-check delay method +# for Nagios. Default is 's'. +# @param [String] ng_max_svc_check_spread The maximum service check spread for +# Nagios. Default is '30'. +# @param [String] ng_svc_interleave_factor The service interleave factor for +# Nagios. Default is 's'. +# @param [String] ng_host_int_check_delay The host inter-check delay method +# for Nagios. Default is 's'. +# @param [String] ng_max_host_check_spread The maximum host check spread for +# Nagios. Default is '30'. +# @param [String] ng_max_concurrent_checks The maximum number of concurrent checks +# for Nagios. Default is '0'. +# @param [String] ng_check_res_reaper_freq The check result reaper frequency for +# Nagios. Default is '10'. +# @param [String] ng_max_check_res_reap_time The maximum check result reaper time +# for Nagios. Default is '30'. ################################################################################ class confdroid_nagios::params ( # main - String $ng_nagios_server = 'nagios.example.net', - Array $ng_reqpackages_server = ['nagios','nagios-devel'], - Array $ng_reqpackages_client = ['net-snmp-utils','nagios-plugins','nagios-plugins-all','nagios-plugins-nrpe','nagios-common'], - String $ng_pkg_ensure = 'present', - Boolean $ng_include_nrpe = true, - String $ng_main_user = 'nagios', - String $ng_main_password = 'nagios', - String $ng_max_check_attempts = '10', - String $ng_status_upd_interval = '10', - String $ng_check_ext_commands = '1', - String $ng_user = 'nagios', - Boolean $ng_enable_target = true, - Boolean $ng_purge_target = true, + String $ng_nagios_server = 'nagios.example.net', + Array $ng_reqpackages_server = ['nagios','nagios-devel'], + Array $ng_reqpackages_client = ['net-snmp-utils','nagios-plugins','nagios-plugins-all','nagios-plugins-nrpe','nagios-common'], + String $ng_pkg_ensure = 'present', + Boolean $ng_include_nrpe = true, + String $ng_main_user = 'nagios', + String $ng_main_password = 'nagios', + String $ng_max_check_attempts = '10', + String $ng_status_upd_interval = '10', + String $ng_check_ext_commands = '1', + String $ng_user = 'nagios', + Boolean $ng_enable_target = true, + Boolean $ng_purge_target = true, # contact groups String $ng_contactgroup_name = 'admins', @@ -147,17 +181,34 @@ class confdroid_nagios::params ( String $ng_contact_email = 'nagiosadmin@example.net', # hostgroups - String $ng_hostgroup_name = 'linux-servers', - String $ng_hostgroup_alias = 'Linux Servers', + String $ng_hostgroup_name = 'linux-servers', + String $ng_hostgroup_alias = 'Linux Servers', # nagios.cfg - String $ng_log_file = '/var/log/nagios/nagios.log', - String $ng_event_broker_options = '-1', - Boolean $ng_enable_query_handler = false, - Array $ng_event_broker_module = [], - String $ng_log_rotation_method = 'd', - String $ng_use_syslog = '1', - String $ng_log_notifications = '1', + String $ng_log_file = '/var/log/nagios/nagios.log', + String $ng_event_broker_options = '-1', + Boolean $ng_enable_query_handler = false, + Array $ng_event_broker_module = [], + String $ng_log_rotation_method = 'd', + String $ng_use_syslog = '1', + String $ng_log_notifications = '1', + String $ng_log_service_retries = '1', + String $ng_log_host_retries = '1', + String $ng_log_event_handlers = '1', + String $ng_log_initial_states = '0', + String $ng_log_current_states = '1', + String $ng_log_external_commands = '1', + String $ng_log_passive_checks = '1', + Array $ng_glob_host_evt_handler = [], + Array $ng_glob_svc_evt_handler = [], + String $ng_svc_int_check_delay = 's', + String $ng_max_svc_check_spread = '30', + String $ng_svc_interleave_factor = 's', + String $ng_host_int_check_delay = 's', + String $ng_max_host_check_spread = '30', + String $ng_max_concurrent_checks = '0', + String $ng_check_res_reaper_freq = '10', + String $ng_max_check_res_reap_time = '30', # cgi.cfg String $ng_context_help = '1', diff --git a/templates/nagios/nagios_cfg.erb b/templates/nagios/nagios_cfg.erb index 40b4bc2..895bd04 100644 --- a/templates/nagios/nagios_cfg.erb +++ b/templates/nagios/nagios_cfg.erb @@ -54,184 +54,33 @@ log_archive_path=<%= @ng_log_archives %> use_syslog=<%= @ng_use_syslog %> log_notifications=<%= @ng_log_notifications %> +log_service_retries=<%= @ng_log_service_retries %> +log_host_retries=<%= @ng_log_host_retries %> +log_event_handlers=<%= @ng_log_event_handlers %> +log_initial_states=<%= @ng_log_initial_states %> +log_current_states=<%= @ng_log_current_states %> +log_external_commands=<%= @ng_log_external_commands %> +log_passive_checks=<%= @ng_log_passive_checks %> -# SERVICE RETRY LOGGING OPTION -# If you don't want service check retries to be logged, set this value -# to 0. If retries should be logged, set the value to 1. +<% unless @ng_glob_host_evt_handler.empty? -%> +<% @ng_glob_host_evt_handler.each do |global_host_event_handler| -%> +global_host_event_handler=<%= @ng_glob_host_evt_handler %> +<% end end -%> +<% unless @ng_glob_svc_evt_handler.empty? -%> +<% @ng_glob_svc_evt_handler.each do |global_service_event_handler| -%> +global_service_event_handler=<%= @ng_glob_svc_evt_handler %> +<% end end -%> -log_service_retries=1 +service_inter_check_delay_method=<%= @ng_svc_int_check_delay %> +max_service_check_spread=<%= @ng_max_svc_check_spread %> +service_interleave_factor=<%= @ng_svc_interleave_factor %> +host_inter_check_delay_method=<%= @ng_host_int_check_delay %> +max_host_check_spread=<%= @ng_max_host_check_spread %> - -# HOST RETRY LOGGING OPTION -# If you don't want host check retries to be logged, set this value to -# 0. If retries should be logged, set the value to 1. - -log_host_retries=1 - - - -# EVENT HANDLER LOGGING OPTION -# If you don't want host and service event handlers to be logged, set -# this value to 0. If event handlers should be logged, set the value -# to 1. - -log_event_handlers=1 - - - -# INITIAL STATES LOGGING OPTION -# If you want Nagios to log all initial host and service states to -# the main log file (the first time the service or host is checked) -# you can enable this option by setting this value to 1. If you -# are not using an external application that does long term state -# statistics reporting, you do not need to enable this option. In -# this case, set the value to 0. - -log_initial_states=0 - - - -# CURRENT STATES LOGGING OPTION -# If you don't want Nagios to log all current host and service states -# after log has been rotated to the main log file, you can disable this -# option by setting this value to 0. Default value is 1. - -log_current_states=1 - - - -# EXTERNAL COMMANDS LOGGING OPTION -# If you don't want Nagios to log external commands, set this value -# to 0. If external commands should be logged, set this value to 1. -# Note: This option does not include logging of passive service -# checks - see the option below for controlling whether or not -# passive checks are logged. - -log_external_commands=1 - - - -# PASSIVE CHECKS LOGGING OPTION -# If you don't want Nagios to log passive host and service checks, set -# this value to 0. If passive checks should be logged, set -# this value to 1. - -log_passive_checks=1 - - - -# GLOBAL HOST AND SERVICE EVENT HANDLERS -# These options allow you to specify a host and service event handler -# command that is to be run for every host or service state change. -# The global event handler is executed immediately prior to the event -# handler that you have optionally specified in each host or -# service definition. The command argument is the short name of a -# command definition that you define in your host configuration file. -# Read the HTML docs for more information. - -#global_host_event_handler=somecommand -#global_service_event_handler=somecommand - - - -# SERVICE INTER-CHECK DELAY METHOD -# This is the method that Nagios should use when initially -# "spreading out" service checks when it starts monitoring. The -# default is to use smart delay calculation, which will try to -# space all service checks out evenly to minimize CPU load. -# Using the dumb setting will cause all checks to be scheduled -# at the same time (with no delay between them)! This is not a -# good thing for production, but is useful when testing the -# parallelization functionality. -# n = None - don't use any delay between checks -# d = Use a "dumb" delay of 1 second between checks -# s = Use "smart" inter-check delay calculation -# x.xx = Use an inter-check delay of x.xx seconds - -service_inter_check_delay_method=s - - - -# MAXIMUM SERVICE CHECK SPREAD -# This variable determines the timeframe (in minutes) from the -# program start time that an initial check of all services should -# be completed. Default is 30 minutes. - -max_service_check_spread=30 - - - -# SERVICE CHECK INTERLEAVE FACTOR -# This variable determines how service checks are interleaved. -# Interleaving the service checks allows for a more even -# distribution of service checks and reduced load on remote -# hosts. Setting this value to 1 is equivalent to how versions -# of Nagios previous to 0.0.5 did service checks. Set this -# value to s (smart) for automatic calculation of the interleave -# factor unless you have a specific reason to change it. -# s = Use "smart" interleave factor calculation -# x = Use an interleave factor of x, where x is a -# number greater than or equal to 1. - -service_interleave_factor=s - - - -# HOST INTER-CHECK DELAY METHOD -# This is the method that Nagios should use when initially -# "spreading out" host checks when it starts monitoring. The -# default is to use smart delay calculation, which will try to -# space all host checks out evenly to minimize CPU load. -# Using the dumb setting will cause all checks to be scheduled -# at the same time (with no delay between them)! -# n = None - don't use any delay between checks -# d = Use a "dumb" delay of 1 second between checks -# s = Use "smart" inter-check delay calculation -# x.xx = Use an inter-check delay of x.xx seconds - -host_inter_check_delay_method=s - - - -# MAXIMUM HOST CHECK SPREAD -# This variable determines the timeframe (in minutes) from the -# program start time that an initial check of all hosts should -# be completed. Default is 30 minutes. - -max_host_check_spread=30 - - - -# MAXIMUM CONCURRENT SERVICE CHECKS -# This option allows you to specify the maximum number of -# service checks that can be run in parallel at any given time. -# Specifying a value of 1 for this variable essentially prevents -# any service checks from being parallelized. A value of 0 -# will not restrict the number of concurrent checks that are -# being executed. - -max_concurrent_checks=0 - - - -# HOST AND SERVICE CHECK REAPER FREQUENCY -# This is the frequency (in seconds!) that Nagios will process -# the results of host and service checks. - -check_result_reaper_frequency=10 - - - - -# MAX CHECK RESULT REAPER TIME -# This is the max amount of time (in seconds) that a single -# check result reaper event will be allowed to run before -# returning control back to Nagios so it can perform other -# duties. - -max_check_result_reaper_time=30 - +max_concurrent_checks=<%= @ng_max_concurrent_checks %> +check_result_reaper_frequency=<%= @ng_check_res_reaper_freq %> +max_check_result_reaper_time=<%= @ng_max_check_res_reap_time %>