mirror of https://github.com/Icinga/icinga2.git
parent
d59054feee
commit
7c4fa22715
|
@ -71,7 +71,7 @@ void CheckResultReader::ReadTimerHandler(void) const
|
||||||
{
|
{
|
||||||
CONTEXT("Processing check result files in '" + GetSpoolDir() + "'");
|
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
|
void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
||||||
|
@ -117,6 +117,8 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
||||||
<< boost::errinfo_errno(errno)
|
<< boost::errinfo_errno(errno)
|
||||||
<< boost::errinfo_file_name(crfile));
|
<< boost::errinfo_file_name(crfile));
|
||||||
|
|
||||||
|
Checkable::Ptr checkable;
|
||||||
|
|
||||||
Host::Ptr host = Host::GetByName(attrs["host_name"]);
|
Host::Ptr host = Host::GetByName(attrs["host_name"]);
|
||||||
|
|
||||||
if (!host) {
|
if (!host) {
|
||||||
|
@ -126,6 +128,7 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (attrs.find("service_description") != attrs.end()) {
|
||||||
Service::Ptr service = host->GetServiceByShortName(attrs["service_description"]);
|
Service::Ptr service = host->GetServiceByShortName(attrs["service_description"]);
|
||||||
|
|
||||||
if (!service) {
|
if (!service) {
|
||||||
|
@ -136,6 +139,10 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkable = service;
|
||||||
|
} else
|
||||||
|
checkable = host;
|
||||||
|
|
||||||
CheckResult::Ptr result = new CheckResult();
|
CheckResult::Ptr result = new CheckResult();
|
||||||
String output = CompatUtility::UnEscapeString(attrs["output"]);
|
String output = CompatUtility::UnEscapeString(attrs["output"]);
|
||||||
std::pair<String, Value> co = PluginUtility::ParseCheckOutput(output);
|
std::pair<String, Value> co = PluginUtility::ParseCheckOutput(output);
|
||||||
|
@ -145,18 +152,13 @@ void CheckResultReader::ProcessCheckResultFile(const String& path) const
|
||||||
result->SetExecutionStart(Convert::ToDouble(attrs["start_time"]));
|
result->SetExecutionStart(Convert::ToDouble(attrs["start_time"]));
|
||||||
result->SetExecutionEnd(Convert::ToDouble(attrs["finish_time"]));
|
result->SetExecutionEnd(Convert::ToDouble(attrs["finish_time"]));
|
||||||
|
|
||||||
service->ProcessCheckResult(result);
|
checkable->ProcessCheckResult(result);
|
||||||
|
|
||||||
Log(LogDebug, "CheckResultReader")
|
Log(LogDebug, "CheckResultReader")
|
||||||
<< "Processed checkresult file for host '" << attrs["host_name"]
|
<< "Processed checkresult file for object '" << checkable->GetName() << "'";
|
||||||
<< "', service '" << attrs["service_description"] << "'";
|
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock olock(service);
|
|
||||||
|
|
||||||
/* Reschedule the next check. The side effect of this is that for as long
|
/* 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
|
* as we receive check result files for a host/service we won't execute any
|
||||||
* active checks. */
|
* active checks. */
|
||||||
service->SetNextCheck(Utility::GetTime() + service->GetCheckInterval());
|
checkable->SetNextCheck(Utility::GetTime() + checkable->GetCheckInterval());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue