}
}
+double Host::GetLastStateUp(void) const
+{
+ ASSERT(!OwnsLock());
+
+ Service::Ptr hc = GetHostCheckService();
+
+ if (!hc)
+ return 0;
+
+ if (hc->GetLastStateOK() > hc->GetLastStateWarning())
+ return hc->GetLastStateOK();
+ else
+ return hc->GetLastStateWarning();
+}
+
+double Host::GetLastStateDown(void) const
+{
+ ASSERT(!OwnsLock());
+
+ Service::Ptr hc = GetHostCheckService();
+
+ if (!hc)
+ return 0;
+
+ return hc->GetLastStateCritical();
+}
+
+double Host::GetLastStateUnreachable(void) const
+{
+ ASSERT(!OwnsLock());
+
+ Service::Ptr hc = GetHostCheckService();
+
+ if (!hc)
+ return 0;
+
+ return hc->GetLastStateUnreachable();
+}
+
double Host::GetLastStateChange(void) const
{
Service::Ptr hc = GetHostCheckService();
StateType GetLastStateType(void) const;
double GetLastStateChange(void) const;
double GetLastHardStateChange(void) const;
+ double GetLastStateUp(void) const;
+ double GetLastStateDown(void) const;
+ double GetLastStateUnreachable(void) const;
static String StateToString(HostState state);
return static_cast<StateType>(ivalue);
}
+void Service::SetLastStateOK(double ts)
+{
+ m_LastStateOK = ts;
+ Touch("last_state_ok");
+}
+
+double Service::GetLastStateOK(void) const
+{
+ if (m_LastStateOK.IsEmpty())
+ return 0;
+
+ return m_LastStateOK;
+}
+
+void Service::SetLastStateWarning(double ts)
+{
+ m_LastStateWarning = ts;
+ Touch("last_state_warning");
+}
+
+double Service::GetLastStateWarning(void) const
+{
+ if (m_LastStateWarning.IsEmpty())
+ return 0;
+
+ return m_LastStateWarning;
+}
+
+void Service::SetLastStateCritical(double ts)
+{
+ m_LastStateCritical = ts;
+ Touch("last_state_critical");
+}
+
+double Service::GetLastStateCritical(void) const
+{
+ if (m_LastStateCritical.IsEmpty())
+ return 0;
+
+ return m_LastStateCritical;
+}
+
+void Service::SetLastStateUnknown(double ts)
+{
+ m_LastStateUnknown = ts;
+ Touch("last_state_unknown");
+}
+
+double Service::GetLastStateUnknown(void) const
+{
+ if (m_LastStateUnknown.IsEmpty())
+ return 0;
+
+ return m_LastStateUnknown;
+}
+
+void Service::SetLastStateUnreachable(double ts)
+{
+ m_LastStateUnreachable = ts;
+ Touch("last_state_unreachable");
+}
+
+double Service::GetLastStateUnreachable(void) const
+{
+ if (m_LastStateUnreachable.IsEmpty())
+ return 0;
+
+ return m_LastStateUnreachable;
+}
+
void Service::SetLastReachable(bool reachable)
{
m_LastReachable = reachable;
bool reachable = IsReachable();
+ if (!reachable)
+ SetLastStateUnreachable(Utility::GetTime());
+
Host::Ptr host = GetHost();
bool host_reachable = true;
attempt = 1;
recovery = true;
ResetNotificationNumbers();
+ SetLastStateOK(Utility::GetTime());
} else {
if (old_attempt >= GetMaxCheckAttempts()) {
SetStateType(StateTypeHard);
}
recovery = false;
+
+ if (cr->Get("state") == StateWarning)
+ SetLastStateWarning(Utility::GetTime());
+ if (cr->Get("state") == StateCritical)
+ SetLastStateCritical(Utility::GetTime());
+ if (cr->Get("state") == StateUnknown)
+ SetLastStateUnknown(Utility::GetTime());
}
SetCurrentCheckAttempt(attempt);
RegisterAttribute("last_result", Attribute_Replicated, &m_LastResult);
RegisterAttribute("last_state_change", Attribute_Replicated, &m_LastStateChange);
RegisterAttribute("last_hard_state_change", Attribute_Replicated, &m_LastHardStateChange);
+ RegisterAttribute("last_state_ok", Attribute_Replicated, &m_LastStateOK);
+ RegisterAttribute("last_state_warning", Attribute_Replicated, &m_LastStateWarning);
+ RegisterAttribute("last_state_critical", Attribute_Replicated, &m_LastStateCritical);
+ RegisterAttribute("last_state_unknown", Attribute_Replicated, &m_LastStateUnknown);
+ RegisterAttribute("last_state_unreachable", Attribute_Replicated, &m_LastStateUnreachable);
RegisterAttribute("last_in_downtime", Attribute_Replicated, &m_LastInDowntime);
RegisterAttribute("enable_active_checks", Attribute_Replicated, &m_EnableActiveChecks);
RegisterAttribute("enable_passive_checks", Attribute_Replicated, &m_EnablePassiveChecks);
void SetLastHardStateChange(double ts);
double GetLastHardStateChange(void) const;
+ void SetLastStateOK(double ts);
+ double GetLastStateOK(void) const;
+ void SetLastStateWarning(double ts);
+ double GetLastStateWarning(void) const;
+ void SetLastStateCritical(double ts);
+ double GetLastStateCritical(void) const;
+ void SetLastStateUnknown(double ts);
+ double GetLastStateUnknown(void) const;
+ void SetLastStateUnreachable(double ts);
+ double GetLastStateUnreachable(void) const;
+
void SetLastReachable(bool reachable);
bool GetLastReachable(void) const;
Attribute<Dictionary::Ptr> m_LastResult;
Attribute<double> m_LastStateChange;
Attribute<double> m_LastHardStateChange;
+ Attribute<double> m_LastStateOK;
+ Attribute<double> m_LastStateWarning;
+ Attribute<double> m_LastStateCritical;
+ Attribute<double> m_LastStateUnknown;
+ Attribute<double> m_LastStateUnreachable;
Attribute<bool> m_LastInDowntime;
Attribute<bool> m_EnableActiveChecks;
Attribute<bool> m_EnablePassiveChecks;