[icinga-checkins] icinga.org: icinga-core/master: core: refuse to start if neb modules fail to load (Andreas Ericsson) refs #3812

git at icinga.org git at icinga.org
Thu Mar 21 17:12:36 CET 2013


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

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Fri Mar  8 19:01:45 2013 +0100

core: refuse to start if neb modules fail to load (Andreas Ericsson) refs #3812

since it will be mandatory to run idoutils once configured, the core
should check if loading was succesful, and otherwise shutdown as well.

---

 Changelog      |    3 +++
 base/icinga.c  |    9 ++++++++-
 base/nebmods.c |    8 +++++++-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 083d2cc..3b9eb34 100644
--- a/Changelog
+++ b/Changelog
@@ -19,6 +19,7 @@ NOTES
 
 ENHANCEMENTS
 * core: introduce warning level -vv on config verification #3510 - MF
+* core: refuse to start if neb modules fail to load (Andreas Ericsson) #3812 - MF
 
 * classic ui: Add "set_expire_ack_by_default" to cgi configuration #3476 - CF
 * classic ui: Add "send_ack_notifications" to cgi configuration (TheCry) #3467 - CF
@@ -77,8 +78,10 @@ FIXES
 CHANGES
 
 * icinga.cfg - enable_state_based_escalation_ranges=0 (disabled if not set) fix for #3441
+
 * core: -v param can be used more than once #3510
 * core: 'Warning: Host ... has no service associated with it!' now happens only in icinga -vv icinga.cfg #3510
+* core: refuse to start if neb modules fail to load #3812
 
 * ido2db.cfg:
 	** use_transactions #3527
diff --git a/base/icinga.c b/base/icinga.c
index 038245e..cc13ad1 100644
--- a/base/icinga.c
+++ b/base/icinga.c
@@ -724,7 +724,14 @@ int main(int argc, char **argv, char **env) {
 
 #ifdef USE_EVENT_BROKER
 			/* load modules */
-			neb_load_all_modules();
+			if (neb_load_all_modules() != OK) {
+                logit(NSLOG_CONFIG_ERROR, ERROR, "Error: NEB module loading failed. Aborting.\n");
+
+                if (daemon_dumps_core)
+                    neb_unload_all_modules(NEBMODULE_FORCE_UNLOAD, NEBMODULE_NEB_SHUTDOWN);
+
+                exit(EXIT_FAILURE);
+            }
 
 			/* send program data to broker */
 			broker_program_state(NEBTYPE_PROCESS_PRELAUNCH, NEBFLAG_NONE, NEBATTR_NONE, NULL);
diff --git a/base/nebmods.c b/base/nebmods.c
index 7efa1ba..2ab53b1 100644
--- a/base/nebmods.c
+++ b/base/nebmods.c
@@ -154,12 +154,18 @@ int neb_free_module_list(void) {
 int neb_load_all_modules(void) {
 	nebmodule *temp_module = NULL;
 	int result = OK;
+    int errors = 0;
 
 	for (temp_module = neb_module_list; temp_module; temp_module = temp_module->next) {
 		result = neb_load_module(temp_module);
+
+        if (result != OK) {
+            logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Failed to load module '%s'.\n", temp_module->filename ? temp_module->filename : "(no file?)");
+            errors++;
+        }
 	}
 
-	return result;
+	return errors ? ERROR : OK;
 }
 
 #ifndef PATH_MAX





More information about the icinga-checkins mailing list