[icinga-checkins] icinga.org: icinga2/master: Use object name if HOSTADDRESS macro isn' t defined.

git at icinga.org git at icinga.org
Tue Jul 2 10:08:31 CEST 2013


Module: icinga2
Branch: master
Commit: acc2bdb875dee753fc17d8a23c960d17ef80bfbd
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=acc2bdb875dee753fc17d8a23c960d17ef80bfbd

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Tue Jul  2 10:06:08 2013 +0200

Use object name if HOSTADDRESS macro isn't defined.

---

 lib/icinga/host.cpp |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index 246fa44..2119a72 100644
--- a/lib/icinga/host.cpp
+++ b/lib/icinga/host.cpp
@@ -610,18 +610,21 @@ bool Host::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *res
 
 	Dictionary::Ptr macros = GetMacros();
 
-	if (macros) {
-		String name = macro;
+	String name = macro;
 
-		if (name == "HOSTADDRESS")
-			name = "address";
-		else if (macro == "HOSTADDRESS6")
-			name = "address6";
+	if (name == "HOSTADDRESS")
+		name = "address";
+	else if (macro == "HOSTADDRESS6")
+		name = "address6";
 
-		if (macros->Contains(name)) {
-			*result = macros->Get(name);
-			return true;
-		}
+	if (macros && macros->Contains(name)) {
+		*result = macros->Get(name);
+		return true;
+	}
+
+	if (macro == "HOSTADDRESS" || macro == "HOSTADDRESS6") {
+		*result = GetName();
+		return true;
 	}
 
 	return false;





More information about the icinga-checkins mailing list