mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 07:04:37 +02:00
Service::CheckCompletedHandler: Convert exceptions to fake check results.
This commit is contained in:
parent
2834edfd71
commit
745e86de97
@ -697,12 +697,27 @@ void Service::CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
|||||||
scheduleInfo->Set("execution_end", Utility::GetTime());
|
scheduleInfo->Set("execution_end", Utility::GetTime());
|
||||||
scheduleInfo->Set("schedule_end", Utility::GetTime());
|
scheduleInfo->Set("schedule_end", Utility::GetTime());
|
||||||
|
|
||||||
|
Dictionary::Ptr result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Value vresult = task->GetResult();
|
Value vresult = task->GetResult();
|
||||||
|
|
||||||
if (vresult.IsObjectType<Dictionary>()) {
|
if (vresult.IsObjectType<Dictionary>())
|
||||||
Dictionary::Ptr result = vresult;
|
result = vresult;
|
||||||
|
} catch (const exception& ex) {
|
||||||
|
stringstream msgbuf;
|
||||||
|
msgbuf << "Exception occured during check for service '"
|
||||||
|
<< GetName() << "': " << ex.what();
|
||||||
|
String message = msgbuf.str();
|
||||||
|
|
||||||
|
Logger::Write(LogWarning, "checker", message);
|
||||||
|
|
||||||
|
result = boost::make_shared<Dictionary>();
|
||||||
|
result->Set("state", StateUnknown);
|
||||||
|
result->Set("output", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result) {
|
||||||
if (!result->Contains("schedule_start"))
|
if (!result->Contains("schedule_start"))
|
||||||
result->Set("schedule_start", scheduleInfo->Get("schedule_start"));
|
result->Set("schedule_start", scheduleInfo->Get("schedule_start"));
|
||||||
|
|
||||||
@ -720,12 +735,6 @@ void Service::CheckCompletedHandler(const Dictionary::Ptr& scheduleInfo,
|
|||||||
|
|
||||||
ProcessCheckResult(result);
|
ProcessCheckResult(result);
|
||||||
}
|
}
|
||||||
} catch (const exception& ex) {
|
|
||||||
stringstream msgbuf;
|
|
||||||
msgbuf << "Exception occured during check for service '"
|
|
||||||
<< GetName() << "': " << ex.what();
|
|
||||||
Logger::Write(LogWarning, "checker", msgbuf.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* figure out when the next check is for this service; the call to
|
/* figure out when the next check is for this service; the call to
|
||||||
* ApplyCheckResult() should've already done this but lets do it again
|
* ApplyCheckResult() should've already done this but lets do it again
|
||||||
|
Loading…
x
Reference in New Issue
Block a user