mirror of https://github.com/Icinga/icinga2.git
Cleaned up NagiosCheckTask.
This commit is contained in:
parent
0634075abd
commit
07b30e19a9
|
@ -47,19 +47,18 @@ void NagiosCheckTask::ScriptFunc(const ScriptTask::Ptr& task, const vector<Varia
|
||||||
macroDicts.push_back(IcingaApplication::GetInstance()->GetMacros());
|
macroDicts.push_back(IcingaApplication::GetInstance()->GetMacros());
|
||||||
string command = MacroProcessor::ResolveMacros(checkCommand, macroDicts);
|
string command = MacroProcessor::ResolveMacros(checkCommand, macroDicts);
|
||||||
|
|
||||||
CheckResult result;
|
|
||||||
|
|
||||||
time_t now;
|
|
||||||
time(&now);
|
|
||||||
result.SetScheduleStart(now);
|
|
||||||
|
|
||||||
Process::Ptr process = boost::make_shared<Process>(command);
|
Process::Ptr process = boost::make_shared<Process>(command);
|
||||||
|
|
||||||
NagiosCheckTask ct(task, process);
|
NagiosCheckTask ct(task, process);
|
||||||
process->Start(boost::bind(&NagiosCheckTask::ProcessFinishedHandler, ct, result));
|
|
||||||
|
time_t now;
|
||||||
|
time(&now);
|
||||||
|
ct.m_Result.SetScheduleStart(now);
|
||||||
|
|
||||||
|
process->Start(boost::bind(&NagiosCheckTask::ProcessFinishedHandler, ct));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NagiosCheckTask::ProcessFinishedHandler(NagiosCheckTask ct, CheckResult result)
|
void NagiosCheckTask::ProcessFinishedHandler(NagiosCheckTask ct)
|
||||||
{
|
{
|
||||||
ProcessResult pr;
|
ProcessResult pr;
|
||||||
|
|
||||||
|
@ -70,12 +69,12 @@ void NagiosCheckTask::ProcessFinishedHandler(NagiosCheckTask ct, CheckResult res
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.SetExecutionStart(pr.ExecutionStart);
|
ct.m_Result.SetExecutionStart(pr.ExecutionStart);
|
||||||
result.SetExecutionEnd(pr.ExecutionEnd);
|
ct.m_Result.SetExecutionEnd(pr.ExecutionEnd);
|
||||||
|
|
||||||
string output = pr.Output;
|
string output = pr.Output;
|
||||||
boost::algorithm::trim(output);
|
boost::algorithm::trim(output);
|
||||||
ProcessCheckOutput(result, output);
|
ProcessCheckOutput(ct.m_Result, output);
|
||||||
|
|
||||||
ServiceState state;
|
ServiceState state;
|
||||||
|
|
||||||
|
@ -94,13 +93,13 @@ void NagiosCheckTask::ProcessFinishedHandler(NagiosCheckTask ct, CheckResult res
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.SetState(state);
|
ct.m_Result.SetState(state);
|
||||||
|
|
||||||
time_t now;
|
time_t now;
|
||||||
time(&now);
|
time(&now);
|
||||||
result.SetScheduleEnd(now);
|
ct.m_Result.SetScheduleEnd(now);
|
||||||
|
|
||||||
ct.m_Task->FinishResult(result.GetDictionary());
|
ct.m_Task->FinishResult(ct.m_Result.GetDictionary());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NagiosCheckTask::ProcessCheckOutput(CheckResult& result, const string& output)
|
void NagiosCheckTask::ProcessCheckOutput(CheckResult& result, const string& output)
|
||||||
|
|
|
@ -31,13 +31,14 @@ public:
|
||||||
static void Register(void);
|
static void Register(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void ProcessFinishedHandler(NagiosCheckTask ct, CheckResult result);
|
static void ProcessFinishedHandler(NagiosCheckTask ct);
|
||||||
static void ProcessCheckOutput(CheckResult& result, const string& output);
|
static void ProcessCheckOutput(CheckResult& result, const string& output);
|
||||||
|
|
||||||
NagiosCheckTask(const ScriptTask::Ptr& task, const Process::Ptr& process);
|
NagiosCheckTask(const ScriptTask::Ptr& task, const Process::Ptr& process);
|
||||||
|
|
||||||
ScriptTask::Ptr m_Task;
|
ScriptTask::Ptr m_Task;
|
||||||
Process::Ptr m_Process;
|
Process::Ptr m_Process;
|
||||||
|
CheckResult m_Result;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue