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