From 93cd1b811e33664f7bdc54b2daa147b6bb87b131 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 27 Sep 2013 07:34:08 +0200 Subject: [PATCH] Make check_source a check result attribute. --- lib/icinga/compatutility.cpp | 8 ++++---- lib/icinga/service-check.cpp | 6 +++--- lib/icinga/service.cpp | 13 ------------- lib/icinga/service.h | 4 ---- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/lib/icinga/compatutility.cpp b/lib/icinga/compatutility.cpp index 1932b1d56..a0a65101b 100644 --- a/lib/icinga/compatutility.cpp +++ b/lib/icinga/compatutility.cpp @@ -178,6 +178,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se String output; String long_output; String perfdata; + String check_source; double schedule_end = -1; String check_period_str; @@ -194,6 +195,8 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se output = output_bag->Get("output"); long_output = output_bag->Get("long_output"); + check_source = cr->Get("check_source"); + perfdata = GetCheckResultPerfdata(cr); schedule_end = cr->Get("schedule_end"); } @@ -260,6 +263,7 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se attr->Set("plugin_output", output); attr->Set("long_plugin_output", long_output); attr->Set("performance_data", perfdata); + attr->Set("check_source", check_source); attr->Set("check_type", (service->GetEnableActiveChecks() ? 1 : 0)); attr->Set("last_check", schedule_end); attr->Set("next_check", service->GetNextCheck()); @@ -285,10 +289,6 @@ Dictionary::Ptr CompatUtility::GetServiceStatusAttributes(const Service::Ptr& se attr->Set("next_notification", next_notification); attr->Set("current_notification_number", notification_number); - String authority = service->GetCheckResultAuthority(); - if (!authority.IsEmpty()) - attr->Set("check_source", authority); - return attr; } diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index ca22a56b4..01048a101 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -456,6 +456,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author if (!cr->Contains("execution_end")) cr->Set("execution_end", now); + if (!cr->Contains("check_source")) + cr->Set("check_source", authority); + bool reachable = IsReachable(); Host::Ptr host = GetHost(); @@ -603,9 +606,6 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr, const String& author olock.Lock(); SetLastCheckResult(cr); - if (!authority.IsEmpty()) - SetCheckResultAuthority(authority); - bool was_flapping, is_flapping; was_flapping = IsFlapping(); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index ac5451755..465befd99 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -328,19 +328,6 @@ std::set Service::GetParentServices(void) const return parents; } -void Service::SetCheckResultAuthority(const String& authority) -{ - m_CheckResultAuthority = authority; -} - -String Service::GetCheckResultAuthority(void) const -{ - if (m_CheckResultAuthority.IsEmpty()) - return "(i2 local)"; - else - return m_CheckResultAuthority; -} - bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const { if (macro == "SERVICEDESC") { diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 1fbcfc865..4d4203c5d 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -142,9 +142,6 @@ public: void AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, double expiry = 0, const String& authority = String()); void ClearAcknowledgement(const String& authority = String()); - void SetCheckResultAuthority(const String& authority); - String GetCheckResultAuthority(void) const; - /* Checks */ shared_ptr GetCheckCommand(void) const; long GetMaxCheckAttempts(void) const; @@ -355,7 +352,6 @@ private: Value m_AcknowledgementExpiry; String m_HostName; Value m_Volatile; - String m_CheckResultAuthority; /* Checks */ String m_CheckCommand;