[icinga-checkins] icinga.org: icinga-core/mfriedrich/stage: Fix idomod de-init after config file errors

git at icinga.org git at icinga.org
Wed Jan 13 18:03:02 CET 2010


Module: icinga-core
Branch: mfriedrich/stage
Commit: 918a17141264cdc572d1f4b30d16c7ef8d611f32
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=918a17141264cdc572d1f4b30d16c7ef8d611f32

Author: Hendrik Baecker <andurin at process-zero.de>
Date:   Sun Jan 10 15:31:55 2010 +0100

Fix idomod de-init after config file errors

idomod is now a little bit more verbose.
Errors in config file will result in a de-init of the whole module:

See icinga.log:
idomod: ERROR - Unknown config file variable 'outputtype'.
idomod: An error occurred while attempting to process module arguments.
Error: Function nebmodule_init() in module '/usr/local/icinga/bin/idomod.o' returned an error.  Module will be unloaded.

closes #250

---

 Changelog                    |    1 +
 module/idoutils/src/idomod.c |   16 ++++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Changelog b/Changelog
index cd77e91..e5dcb8b 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ Icinga 1.0.x Change Log
 * core: fix segfault in cmd.cgi
 * core: fix event broker callback function self de-registering for callbacks (Sean Millichamp)
 * core: added missing sound.js provided by scriptaculous
+* core: fix idomod doesn't de-initialize after config error
 
 1.0 Stable - 16/12/2009
 * core: create webserver conf.d dir if not existing
diff --git a/module/idoutils/src/idomod.c b/module/idoutils/src/idomod.c
index 46c9534..d8c8432 100644
--- a/module/idoutils/src/idomod.c
+++ b/module/idoutils/src/idomod.c
@@ -3,10 +3,10 @@
  * IDOMOD.C - Icinga Data Output Event Broker Module
  *
  * Copyright (c) 2005-2007 Ethan Galstad
- * Copyright (c) 2009 Icinga Development Team (http://www.icinga.org)
+ * Copyright (c) 2009-2010 Icinga Development Team (http://www.icinga.org)
  *
  * First Written: 05-19-2005
- * Last Modified: 12-16-2009 
+ * Last Modified: 01-10-2010
  *
  *****************************************************************************/
 
@@ -375,6 +375,8 @@ int ndomod_process_config_var(char *arg){
 	char *var=NULL;
 	char *val=NULL;
 
+	char temp_buffer[NDOMOD_MAX_BUFLEN];
+
 	/* split var/val */
 	var=strtok(arg,"=");
 	val=strtok(NULL,"\n");
@@ -390,7 +392,7 @@ int ndomod_process_config_var(char *arg){
 	/* process the variable... */
 
 	if(!strcmp(var,"config_file"))
-		ndomod_process_config_file(val);
+		return ndomod_process_config_file(val);
 
 	else if(!strcmp(var,"instance_name"))
 		ndomod_instance_name=strdup(val);
@@ -461,8 +463,14 @@ int ndomod_process_config_var(char *arg){
 			}
 	}
 
-	else
+	else {
+		/* log an error message to the Icinga log file */
+		snprintf(temp_buffer,sizeof(temp_buffer)-1,"idomod: ERROR - Unknown config file variable '%s'.\n", var);
+		temp_buffer[sizeof(temp_buffer)-1]='\x0';
+		ndomod_write_to_logs(temp_buffer,NSLOG_INFO_MESSAGE);
+
 		return NDO_ERROR;
+	}
 
 	return NDO_OK;
         }





More information about the icinga-checkins mailing list