From: Gunnar Beutner Date: Tue, 13 Oct 2015 06:56:12 +0000 (+0200) Subject: Fix support for host checks in CheckResultReader X-Git-Tag: v2.3.11~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac11653bbeab4a62ea56eb807dd04c0575c95be9;p=icinga2 Fix support for host checks in CheckResultReader fixes #10348 --- diff --git a/lib/compat/checkresultreader.cpp b/lib/compat/checkresultreader.cpp index f65ddfc64..4f57f978f 100644 --- a/lib/compat/checkresultreader.cpp +++ b/lib/compat/checkresultreader.cpp @@ -70,7 +70,7 @@ void CheckResultReader::ReadTimerHandler(void) const { CONTEXT("Processing check result files in '" + GetSpoolDir() + "'"); - Utility::Glob(GetSpoolDir() + "/c??????.ok", boost::bind(&CheckResultReader::ProcessCheckResultFile, this, _1)); + Utility::Glob(GetSpoolDir() + "/c??????.ok", boost::bind(&CheckResultReader::ProcessCheckResultFile, this, _1), GlobFile); } void CheckResultReader::ProcessCheckResultFile(const String& path) const @@ -116,6 +116,8 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const << boost::errinfo_errno(errno) << boost::errinfo_file_name(crfile)); + Checkable::Ptr checkable; + Host::Ptr host = Host::GetByName(attrs["host_name"]); if (!host) { @@ -125,15 +127,20 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const return; } - Service::Ptr service = host->GetServiceByShortName(attrs["service_description"]); + if (attrs.find("service_description") != attrs.end()) { + Service::Ptr service = host->GetServiceByShortName(attrs["service_description"]); - if (!service) { - Log(LogWarning, "CheckResultReader") - << "Ignoring checkresult file for host '" << attrs["host_name"] - << "', service '" << attrs["service_description"] << "': Service does not exist."; + if (!service) { + Log(LogWarning, "CheckResultReader") + << "Ignoring checkresult file for host '" << attrs["host_name"] + << "', service '" << attrs["service_description"] << "': Service does not exist."; - return; - } + return; + } + + checkable = service; + } else + checkable = host; CheckResult::Ptr result = new CheckResult(); String output = CompatUtility::UnEscapeString(attrs["output"]); @@ -144,18 +151,13 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const result->SetExecutionStart(Convert::ToDouble(attrs["start_time"])); result->SetExecutionEnd(Convert::ToDouble(attrs["finish_time"])); - service->ProcessCheckResult(result); + checkable->ProcessCheckResult(result); Log(LogDebug, "CheckResultReader") - << "Processed checkresult file for host '" << attrs["host_name"] - << "', service '" << attrs["service_description"] << "'"; - - { - ObjectLock olock(service); + << "Processed checkresult file for object '" << checkable->GetName() << "'"; - /* Reschedule the next check. The side effect of this is that for as long - * as we receive check result files for a service we won't execute any - * active checks. */ - service->SetNextCheck(Utility::GetTime() + service->GetCheckInterval()); - } + /* Reschedule the next check. The side effect of this is that for as long + * as we receive check result files for a host/service we won't execute any + * active checks. */ + checkable->SetNextCheck(Utility::GetTime() + checkable->GetCheckInterval()); }