From 5af48f2f93c03efcb5dcacd9510b252f2237bbdc Mon Sep 17 00:00:00 2001 From: 12ww1160 <12ww1160@confdroid.com> Date: Sat, 7 Mar 2026 11:37:56 +0100 Subject: [PATCH] OP#436 add file controls --- manifests/params.pp | 19 ++++++ templates/nagios/nagios_cfg.erb | 106 ++++---------------------------- 2 files changed, 31 insertions(+), 94 deletions(-) diff --git a/manifests/params.pp b/manifests/params.pp index e7e3d6c..0d21c3a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -105,6 +105,18 @@ # group. Default is 'nagiosadmin'. # @param [Boolean] ng_purge_target Whether to purge unmanaged host and services # configuration files. Default is true. +# @param [String] ng_event_broker_options The event broker options for Nagios. +# Default is '-1'. +# @param [Boolean] ng_enable_query_handler Whether to enable the Nagios query +# handler. Default is false. +# @param [Array] ng_event_broker_module The event broker modules for Nagios. +# Default is []. +# @param [String] ng_log_rotation_method The log rotation method for Nagios. +# Default is 'd'. +# @param [String] ng_use_syslog Whether to use syslog for logging in Nagios. +# Default is '1'. +# @param [String] ng_log_notifications Whether to log notifications in Nagios. +# Default is '1'. ################################################################################ class confdroid_nagios::params ( @@ -140,6 +152,12 @@ class confdroid_nagios::params ( # 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', # cgi.cfg String $ng_context_help = '1', @@ -257,6 +275,7 @@ class confdroid_nagios::params ( $ng_status_file = "${ng_spool_dir}/status.dat" $ng_command_file = "${ng_cmd_dir}/nagios.cmd" $ng_lock_file = "${ng_run_dir}/nagios.pid" + $ng_temp_file = "${ng_spool_dir}/nagios.tmp" ## old $ng_taccgi_erb = 'confdroid_nagios/selinux/taccgi.erb' diff --git a/templates/nagios/nagios_cfg.erb b/templates/nagios/nagios_cfg.erb index 9e4cb5f..40b4bc2 100644 --- a/templates/nagios/nagios_cfg.erb +++ b/templates/nagios/nagios_cfg.erb @@ -34,107 +34,25 @@ check_external_commands=<%= @ng_check_ext_commands %> command_file=<%= @ng_command_file %> +<% if @ng_enable_query_handler == true -%> query_socket=<%= @ng_cmd_dir %>/nagios.qh - -# LOCK FILE -# This is the lockfile that Nagios will use to store its PID number -# in when it is running in daemon mode. +<% end -%> lock_file=<%= @ng_lock_file %> - - - -# TEMP FILE -# This is a temporary file that is used as scratch space when Nagios -# updates the status log, cleans the comment file, etc. This file -# is created, used, and deleted throughout the time that Nagios is -# running. - -temp_file=/var/spool/nagios/nagios.tmp - - - -# TEMP PATH -# This is path where Nagios can create temp files for service and -# host check results, etc. - +temp_file=<%= @ng_temp_file %> temp_path=/tmp +event_broker_options=<%= @ng_event_broker_options %> +<% unless @ng_event_broker_module.empty? -%> +<% @ng_event_broker_module.each do |broker_module| -%> +broker_module=<%= broker_module %> +<% end end -%> -# EVENT BROKER OPTIONS -# Controls what (if any) data gets sent to the event broker. -# Values: 0 = Broker nothing -# -1 = Broker everything -# = See documentation - -event_broker_options=-1 - - - -# EVENT BROKER MODULE(S) -# This directive is used to specify an event broker module that should -# by loaded by Nagios at startup. Use multiple directives if you want -# to load more than one module. Arguments that should be passed to -# the module at startup are separated from the module path by a space. -# -#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING -#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -# -# Do NOT overwrite modules while they are being used by Nagios or Nagios -# will crash in a fiery display of SEGFAULT glory. This is a bug/limitation -# either in dlopen(), the kernel, and/or the filesystem. And maybe Nagios... -# -# The correct/safe way of updating a module is by using one of these methods: -# 1. Shutdown Nagios, replace the module file, restart Nagios -# 2. Delete the original module file, move the new module file into place, -# restart Nagios -# -# Example: -# -# broker_module= [moduleargs] - -#broker_module=/somewhere/module1.o -#broker_module=/somewhere/module2.o arg1 arg2=3 debug=0 - - - -# LOG ROTATION METHOD -# This is the log rotation method that Nagios should use to rotate -# the main log file. Values are as follows.. -# n = None - don't rotate the log -# h = Hourly rotation (top of the hour) -# d = Daily rotation (midnight every day) -# w = Weekly rotation (midnight on Saturday evening) -# m = Monthly rotation (midnight last day of month) - -log_rotation_method=d - - - -# LOG ARCHIVE PATH -# This is the directory where archived (rotated) log files should be -# placed (assuming you've chosen to do log rotation). - -log_archive_path=/var/log/nagios/archives - - - -# LOGGING OPTIONS -# If you want messages logged to the syslog facility, as well as the -# Nagios log file set this option to 1. If not, set it to 0. - -use_syslog=1 - - - -# NOTIFICATION LOGGING OPTION -# If you don't want notifications to be logged, set this value to 0. -# If notifications should be logged, set the value to 1. - -log_notifications=1 - +log_rotation_method=<%= @ng_log_rotation_method %> +log_archive_path=<%= @ng_log_archives %> +use_syslog=<%= @ng_use_syslog %> +log_notifications=<%= @ng_log_notifications %> # SERVICE RETRY LOGGING OPTION