2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2013-11-09 14:22:38 +01:00
|
|
|
|
2014-05-25 16:23:35 +02:00
|
|
|
#include "icinga/checkresult.hpp"
|
2018-01-18 13:50:38 +01:00
|
|
|
#include "icinga/checkresult-ti.cpp"
|
2015-07-28 17:12:00 +02:00
|
|
|
#include "base/scriptglobal.hpp"
|
2013-11-09 14:22:38 +01:00
|
|
|
|
|
|
|
using namespace icinga;
|
|
|
|
|
|
|
|
REGISTER_TYPE(CheckResult);
|
2015-07-28 17:12:00 +02:00
|
|
|
|
2017-11-21 14:15:29 +01:00
|
|
|
INITIALIZE_ONCE([]() {
|
2023-01-09 17:09:46 +01:00
|
|
|
ScriptGlobal::Set("Icinga.ServiceOK", ServiceOK);
|
|
|
|
ScriptGlobal::Set("Icinga.ServiceWarning", ServiceWarning);
|
|
|
|
ScriptGlobal::Set("Icinga.ServiceCritical", ServiceCritical);
|
|
|
|
ScriptGlobal::Set("Icinga.ServiceUnknown", ServiceUnknown);
|
2015-07-28 17:12:00 +02:00
|
|
|
|
2023-01-09 17:09:46 +01:00
|
|
|
ScriptGlobal::Set("Icinga.HostUp", HostUp);
|
|
|
|
ScriptGlobal::Set("Icinga.HostDown", HostDown);
|
2017-11-21 14:15:29 +01:00
|
|
|
})
|
2016-05-10 11:44:14 +02:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
double CheckResult::CalculateExecutionTime() const
|
2016-05-10 11:44:14 +02:00
|
|
|
{
|
|
|
|
return GetExecutionEnd() - GetExecutionStart();
|
|
|
|
}
|
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
double CheckResult::CalculateLatency() const
|
2016-05-10 11:44:14 +02:00
|
|
|
{
|
|
|
|
double latency = (GetScheduleEnd() - GetScheduleStart()) - CalculateExecutionTime();
|
|
|
|
|
|
|
|
if (latency < 0)
|
|
|
|
latency = 0;
|
|
|
|
|
|
|
|
return latency;
|
|
|
|
}
|