[icinga-checkins] icinga.org: icinga-core/r1.8: core: fix keep_unknown_macros still exposes wrong warnings to logs refs #3725

git at icinga.org git at icinga.org
Mon Mar 4 19:21:43 CET 2013


Module: icinga-core
Branch: r1.8
Commit: 251a130aae53c4e22e4439ede6411ad963a3a25c
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=251a130aae53c4e22e4439ede6411ad963a3a25c

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu Feb 21 20:12:31 2013 +0100

core: fix keep_unknown_macros still exposes wrong warnings to logs refs #3725

Conflicts:
	Changelog

---

 Changelog       |    2 ++
 common/macros.c |   13 ++++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index daeaac4..6c3887a 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,8 @@ UPGRADE NOTES
 1.8.5 - XX/XX/2013
 
 FIXES
+* core: fix keep_unknown_macros still exposes wrong warnings to logs #3725 - MF
+
 * classic ui: fixed JSON output is insufficiently escaped #3541 - RB
 * classic ui: fixed segfault when reading malformed log entries #3528 - RB
 
diff --git a/common/macros.c b/common/macros.c
index 0b4a32c..fd5fe97 100644
--- a/common/macros.c
+++ b/common/macros.c
@@ -200,13 +200,20 @@ int process_macros_r(icinga_macros *mac, char *input_buffer, char **output_buffe
 
 			/* grab the macro value */
 			result = grab_macro_value_r(mac, temp_buffer, &selected_macro, &clean_options, &free_macro);
-			log_debug_info(DEBUGL_MACROS, 2, "  Processed '%s', Clean Options: %d, Free: %d\n", temp_buffer, clean_options, free_macro);
+			log_debug_info(DEBUGL_MACROS, 2, "  Processed '%s', Clean Options: %d, Free: %d\n, Value: '%s'", temp_buffer, clean_options, free_macro, selected_macro ? selected_macro : "");
 
 			/* an error occurred - we couldn't parse the macro, so continue on */
 			if (result == ERROR) {
 				/* empty string still could mean that we hit the escaped $, so log an error in all other cases */
-				if(strcmp(temp_buffer, ""))
-					logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: An error occurred processing macro '%s'!\n", temp_buffer);
+				/* the error tells the user that the macro is valid, but value fetching contained error*/
+				if(strcmp(temp_buffer, "")) {
+					log_debug_info(DEBUGL_MACROS, 2, " Warning: Error grabbing macro '%s' value '%s'! Maybe used in the wrong scope? Check the docs.\n", temp_buffer, selected_macro ? selected_macro : "" );
+#ifdef NSCORE
+					if (keep_unknown_macros == FALSE) {
+						logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Error grabbing macro '%s' value '%s'! Maybe used in the wrong scope? Check the docs.\n", temp_buffer, selected_macro ? selected_macro : "" );
+					}
+#endif
+				}
 
 				if (free_macro == TRUE)
 					my_free(selected_macro);





More information about the icinga-checkins mailing list