[icinga-checkins] icinga.org: icinga2/master: Implemented some more dynamic macros.

git at icinga.org git at icinga.org
Mon Feb 11 16:29:35 CET 2013


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

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Mon Feb 11 16:29:23 2013 +0100

Implemented some more dynamic macros.

---

 lib/icinga/host.cpp    |    1 +
 lib/icinga/service.cpp |   10 ++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp
index b0df21b..9f8cb8c 100644
--- a/lib/icinga/host.cpp
+++ b/lib/icinga/host.cpp
@@ -423,6 +423,7 @@ Dictionary::Ptr Host::CalculateDynamicMacros(void) const
 	Dictionary::Ptr macros = boost::make_shared<Dictionary>();
 
 	macros->Set("HOSTNAME", GetName());
+	macros->Set("HOSTALIAS", GetName());
 	macros->Set("HOSTDISPLAYNAME", GetDisplayName());
 	macros->Set("HOSTSTATE", "DERP");
 
diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp
index f808494..bf712f9 100644
--- a/lib/icinga/service.cpp
+++ b/lib/icinga/service.cpp
@@ -284,5 +284,15 @@ Dictionary::Ptr Service::CalculateDynamicMacros(void) const
 	macros->Set("SERVICEATTEMPT", GetCurrentCheckAttempt());
 	macros->Set("MAXSERVICEATTEMPT", GetMaxCheckAttempts());
 
+	Dictionary::Ptr cr = GetLastCheckResult();
+
+	if (cr) {
+		macros->Set("SERVICEOUTPUT", cr->Get("output"));
+		macros->Set("SERVICEPERFDATA", cr->Get("performance_data_raw"));
+	} else {
+		macros->Set("SERVICEOUTPUT", "");
+		macros->Set("SERVICEPERFDATA", "");
+	}
+
 	return macros;
 }





More information about the icinga-checkins mailing list