From 2d393eab289c9a8a760cae9a48ca102581c922be Mon Sep 17 00:00:00 2001 From: Stephan Platz Date: Sun, 25 Jan 2015 14:30:05 +0100 Subject: [PATCH] Add macro "check_source" for hosts and services to use them in notification mails fixes #8277 Signed-off-by: Gunnar Beutner --- doc/3-monitoring-basics.md | 2 ++ lib/icinga/host.cpp | 3 +++ lib/icinga/service.cpp | 3 +++ 3 files changed, 8 insertions(+) diff --git a/doc/3-monitoring-basics.md b/doc/3-monitoring-basics.md index 461ca6604..6059cf660 100644 --- a/doc/3-monitoring-basics.md +++ b/doc/3-monitoring-basics.md @@ -2045,6 +2045,7 @@ hosts or services: host.output | The last check's output. host.perfdata | The last check's performance data. host.last_check | The timestamp when the last check was executed. + host.check_source | The monitoring instance that performed the last check. host.num_services | Number of services associated with the host. host.num_services_ok | Number of services associated with the host which are in an `OK` state. host.num_services_warning | Number of services associated with the host which are in a `WARNING` state. @@ -2076,6 +2077,7 @@ services: service.output | The last check's output. service.perfdata | The last check's performance data. service.last_check | The timestamp when the last check was executed. + service.check_source | The monitoring instance that performed the last check. ### Command Runtime Macros diff --git a/lib/icinga/host.cpp b/lib/icinga/host.cpp index d6813e5f0..05c73f731 100644 --- a/lib/icinga/host.cpp +++ b/lib/icinga/host.cpp @@ -280,6 +280,9 @@ bool Host::ResolveMacro(const String& macro, const CheckResult::Ptr&, Value *res } else if (macro == "last_check") { *result = Convert::ToString((long)cr->GetScheduleStart()); return true; + } else if (macro == "check_source") { + *result = cr->GetCheckSource(); + return true; } } diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index e698309a0..4b526a4f6 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -178,6 +178,9 @@ bool Service::ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Valu } else if (macro == "last_check") { *result = Convert::ToString((long)cr->GetExecutionEnd()); return true; + } else if (macro == "check_source") { + *result = cr->GetCheckSource(); + return true; } }