Introduce Application::GetUptime()

This commit is contained in:
Michael Friedrich 2020-01-31 16:49:49 +01:00
parent 2f82047737
commit ae8a0b6a64
5 changed files with 10 additions and 3 deletions

View File

@ -1162,6 +1162,11 @@ void Application::SetMainTime(double ts)
m_MainTime = ts;
}
double Application::GetUptime()
{
return Utility::GetTime() - m_StartTime;
}
bool Application::GetScriptDebuggerEnabled()
{
return m_ScriptDebuggerEnabled;

View File

@ -98,6 +98,8 @@ public:
static double GetMainTime();
static void SetMainTime(double ts);
static double GetUptime();
static bool GetScriptDebuggerEnabled();
static void SetScriptDebuggerEnabled(bool enabled);

View File

@ -329,7 +329,7 @@ void CIB::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) {
status->Set("num_services_handled", ss.services_handled);
status->Set("num_services_problem", ss.services_problem);
double uptime = Utility::GetTime() - Application::GetStartTime();
double uptime = Application::GetUptime();
status->Set("uptime", uptime);
HostStatistics hs = CalculateHostStats();

View File

@ -102,7 +102,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
perfdata->Add(new PerfdataValue("num_services_handled", ss.services_handled));
perfdata->Add(new PerfdataValue("num_services_problem", ss.services_problem));
double uptime = Utility::GetTime() - Application::GetStartTime();
double uptime = Application::GetUptime();
perfdata->Add(new PerfdataValue("uptime", uptime));
HostStatistics hs = CIB::CalculateHostStats();

View File

@ -25,7 +25,7 @@ void RandomCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
return;
double now = Utility::GetTime();
double uptime = now - Application::GetStartTime();
double uptime = Application::GetUptime();
String output = "Hello from " + IcingaApplication::GetInstance()->GetNodeName()
+ ". Icinga 2 has been running for " + Utility::FormatDuration(uptime)