mirror of https://github.com/Icinga/icinga2.git
Introduce Application::GetUptime()
This commit is contained in:
parent
2f82047737
commit
ae8a0b6a64
|
@ -1162,6 +1162,11 @@ void Application::SetMainTime(double ts)
|
||||||
m_MainTime = ts;
|
m_MainTime = ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double Application::GetUptime()
|
||||||
|
{
|
||||||
|
return Utility::GetTime() - m_StartTime;
|
||||||
|
}
|
||||||
|
|
||||||
bool Application::GetScriptDebuggerEnabled()
|
bool Application::GetScriptDebuggerEnabled()
|
||||||
{
|
{
|
||||||
return m_ScriptDebuggerEnabled;
|
return m_ScriptDebuggerEnabled;
|
||||||
|
|
|
@ -98,6 +98,8 @@ public:
|
||||||
static double GetMainTime();
|
static double GetMainTime();
|
||||||
static void SetMainTime(double ts);
|
static void SetMainTime(double ts);
|
||||||
|
|
||||||
|
static double GetUptime();
|
||||||
|
|
||||||
static bool GetScriptDebuggerEnabled();
|
static bool GetScriptDebuggerEnabled();
|
||||||
static void SetScriptDebuggerEnabled(bool enabled);
|
static void SetScriptDebuggerEnabled(bool enabled);
|
||||||
|
|
||||||
|
|
|
@ -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_handled", ss.services_handled);
|
||||||
status->Set("num_services_problem", ss.services_problem);
|
status->Set("num_services_problem", ss.services_problem);
|
||||||
|
|
||||||
double uptime = Utility::GetTime() - Application::GetStartTime();
|
double uptime = Application::GetUptime();
|
||||||
status->Set("uptime", uptime);
|
status->Set("uptime", uptime);
|
||||||
|
|
||||||
HostStatistics hs = CalculateHostStats();
|
HostStatistics hs = CalculateHostStats();
|
||||||
|
|
|
@ -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_handled", ss.services_handled));
|
||||||
perfdata->Add(new PerfdataValue("num_services_problem", ss.services_problem));
|
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));
|
perfdata->Add(new PerfdataValue("uptime", uptime));
|
||||||
|
|
||||||
HostStatistics hs = CIB::CalculateHostStats();
|
HostStatistics hs = CIB::CalculateHostStats();
|
||||||
|
|
|
@ -25,7 +25,7 @@ void RandomCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
double uptime = now - Application::GetStartTime();
|
double uptime = Application::GetUptime();
|
||||||
|
|
||||||
String output = "Hello from " + IcingaApplication::GetInstance()->GetNodeName()
|
String output = "Hello from " + IcingaApplication::GetInstance()->GetNodeName()
|
||||||
+ ". Icinga 2 has been running for " + Utility::FormatDuration(uptime)
|
+ ". Icinga 2 has been running for " + Utility::FormatDuration(uptime)
|
||||||
|
|
Loading…
Reference in New Issue