[icinga-checkins] icinga.org: icinga-core/master: New config option to enable/ disable logging in to the daemon log file

git at icinga.org git at icinga.org
Thu Sep 2 12:47:34 CEST 2010


Module: icinga-core
Branch: master
Commit: d80c3ac871d8e756244b315faf0fe0ece20deda9
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=d80c3ac871d8e756244b315faf0fe0ece20deda9

Author: Massimo Forni <forni.massimo at gmail.com>
Date:   Fri Aug 13 09:28:00 2010 +0200

New config option to enable/disable logging in to the daemon log file

fixes #311

---

 Changelog                   |    1 +
 base/config.c               |   12 ++++++++++++
 base/icinga.c               |    1 +
 base/logging.c              |    5 +++++
 base/utils.c                |    3 +++
 include/icinga.h            |    1 +
 sample-config/icinga.cfg.in |   10 +++++++++-
 7 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/Changelog b/Changelog
index f90c993..98e5ea0 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ Icinga 1.0.x Change Log
 
 ENHANCEMENTS
 * core: add eventhandler override (Sven Nierlein)
+* core: add config option to disable logging in to the daemon log file
 
 * classic ui: add commands expander to config display (Jochen Bern)
 	- $ARGn$ substitution will be shown between command_line and
diff --git a/base/config.c b/base/config.c
index 6d23112..e89ea3e 100644
--- a/base/config.c
+++ b/base/config.c
@@ -64,6 +64,7 @@ extern char     *illegal_output_chars;
 extern int      use_regexp_matches;
 extern int      use_true_regexp_matching;
 
+extern int      use_daemon_log;
 extern int      use_syslog;
 extern int      use_syslog_local_facility;
 extern int      syslog_local_facility;
@@ -520,6 +521,17 @@ int read_main_config_file(char *main_config_file){
 			macro_x[MACRO_ADMINPAGER]=(char *)strdup(value);
 		        }
 
+        else if(!strcmp(variable,"use_daemon_log")){
+
+			if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
+				asprintf(&error_message,"Illegal value for use_daemon_log");
+				error=TRUE;
+				break;
+				}
+
+			use_daemon_log=(atoi(value)>0)?TRUE:FALSE;
+            }
+
 		else if(!strcmp(variable,"use_syslog")){
 
 			if(strlen(value)!=1||value[0]<'0'||value[0]>'1'){
diff --git a/base/icinga.c b/base/icinga.c
index 57651a5..53c998e 100644
--- a/base/icinga.c
+++ b/base/icinga.c
@@ -85,6 +85,7 @@ char            *illegal_output_chars=NULL;
 int             use_regexp_matches=FALSE;
 int             use_true_regexp_matching=FALSE;
 
+int             use_daemon_log=DEFAULT_USE_DAEMON_LOG;
 int		use_syslog=DEFAULT_USE_SYSLOG;
 int		use_syslog_local_facility=DEFAULT_USE_SYSLOG_LOCAL_FACILITY;
 int		syslog_local_facility=DEFAULT_SYSLOG_LOCAL_FACILITY;
diff --git a/base/logging.c b/base/logging.c
index d865cd5..44ae5c5 100644
--- a/base/logging.c
+++ b/base/logging.c
@@ -39,6 +39,7 @@ extern char     *macro_x[MACRO_X_COUNT];
 extern host     *host_list;
 extern service  *service_list;
 
+extern int      use_daemon_log;
 extern int	use_syslog;
 extern int	use_syslog_local_facility;
 extern int	syslog_local_facility;
@@ -157,6 +158,10 @@ int write_to_log(char *buffer, unsigned long data_type, time_t *timestamp){
 	if(verify_config==TRUE || test_scheduling==TRUE)
 		return OK;
 
+	/* bail out if we shouldn't write to daemon log */
+	if(use_daemon_log==FALSE)
+		return OK;
+
 	/* make sure we can log this type of entry */
 	if(!(data_type & logging_options))
 		return OK;
diff --git a/base/utils.c b/base/utils.c
index 4894213..de9594d 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -100,6 +100,7 @@ extern int      daemon_dumps_core;
 
 extern int      nagios_pid;
 
+extern int      use_daemon_log;
 extern int	use_syslog;
 extern int	use_syslog_local_facility;
 extern int	syslog_local_facility;
@@ -4598,6 +4599,8 @@ int reset_variables(void){
 	use_regexp_matches=FALSE;
 	use_true_regexp_matching=FALSE;
 
+	use_daemon_log=DEFAULT_USE_DAEMON_LOG;
+
 	use_syslog=DEFAULT_USE_SYSLOG;
 	use_syslog_local_facility=DEFAULT_USE_SYSLOG_LOCAL_FACILITY;
 	syslog_local_facility=DEFAULT_SYSLOG_LOCAL_FACILITY;
diff --git a/include/icinga.h b/include/icinga.h
index 7900f33..52eb68d 100644
--- a/include/icinga.h
+++ b/include/icinga.h
@@ -51,6 +51,7 @@ extern "C" {
 
 /******************* DEFAULT VALUES *******************/
 
+#define DEFAULT_USE_DAEMON_LOG              			1   /* log all events in the daemon log file? 1=yes, 0=no */
 #define DEFAULT_LOG_LEVEL					1	/* log all events to main log file */
 #define DEFAULT_USE_SYSLOG					1	/* log events to syslog? 1=yes, 0=no */
 #define DEFAULT_USE_SYSLOG_LOCAL_FACILITY			0	/* log events to a local facility instead of the default? 1=yes, 0=no */
diff --git a/sample-config/icinga.cfg.in b/sample-config/icinga.cfg.in
index 93e91c3..e0b1987 100644
--- a/sample-config/icinga.cfg.in
+++ b/sample-config/icinga.cfg.in
@@ -269,7 +269,15 @@ log_archive_path=@localstatedir@/archives
 
 
 
-# LOGGING OPTIONS
+# LOGGING OPTIONS FOR DAEMON
+# If you want messages logged to the daemon log file (usually icinga.log).
+# Default option is 1 (yes), the other valid option is 0 (no)
+
+use_daemon_log=1
+
+
+
+# LOGGING OPTIONS FOR SYSLOG
 # If you want messages logged to the syslog facility, as well as the
 # Icinga log file set this option to 1.  If not, set it to 0.
 





More information about the icinga-checkins mailing list