mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-22 21:24:41 +02:00
Merge pull request #7096 from Icinga/feature/derivative-states
Expose derivative states via API
This commit is contained in:
commit
fdb1a36ab6
@ -139,6 +139,21 @@ int Checkable::GetSeverity() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Checkable::GetReachable() const
|
||||||
|
{
|
||||||
|
return IsReachable();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Checkable::GetProblem() const
|
||||||
|
{
|
||||||
|
return !IsStateOK(GetStateRaw());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Checkable::GetHandled() const
|
||||||
|
{
|
||||||
|
return GetProblem() && (IsInDowntime() || IsAcknowledged());
|
||||||
|
}
|
||||||
|
|
||||||
void Checkable::NotifyFixedDowntimeStart(const Downtime::Ptr& downtime)
|
void Checkable::NotifyFixedDowntimeStart(const Downtime::Ptr& downtime)
|
||||||
{
|
{
|
||||||
if (!downtime->GetFixed())
|
if (!downtime->GetFixed())
|
||||||
|
@ -85,6 +85,9 @@ public:
|
|||||||
void ClearAcknowledgement(const MessageOrigin::Ptr& origin = nullptr);
|
void ClearAcknowledgement(const MessageOrigin::Ptr& origin = nullptr);
|
||||||
|
|
||||||
int GetSeverity() const override;
|
int GetSeverity() const override;
|
||||||
|
bool GetReachable() const override;
|
||||||
|
bool GetProblem() const override;
|
||||||
|
bool GetHandled() const override;
|
||||||
|
|
||||||
/* Checks */
|
/* Checks */
|
||||||
intrusive_ptr<CheckCommand> GetCheckCommand() const;
|
intrusive_ptr<CheckCommand> GetCheckCommand() const;
|
||||||
@ -96,7 +99,7 @@ public:
|
|||||||
void UpdateNextCheck(const MessageOrigin::Ptr& origin = nullptr);
|
void UpdateNextCheck(const MessageOrigin::Ptr& origin = nullptr);
|
||||||
|
|
||||||
bool HasBeenChecked() const;
|
bool HasBeenChecked() const;
|
||||||
virtual bool IsStateOK(ServiceState state) = 0;
|
virtual bool IsStateOK(ServiceState state) const = 0;
|
||||||
|
|
||||||
double GetLastCheck() const final;
|
double GetLastCheck() const final;
|
||||||
|
|
||||||
|
@ -123,6 +123,15 @@ abstract class Checkable : CustomVarObject
|
|||||||
[no_storage] int severity {
|
[no_storage] int severity {
|
||||||
get;
|
get;
|
||||||
};
|
};
|
||||||
|
[no_storage] bool reachable {
|
||||||
|
get;
|
||||||
|
};
|
||||||
|
[no_storage] bool problem {
|
||||||
|
get;
|
||||||
|
};
|
||||||
|
[no_storage] bool handled {
|
||||||
|
get;
|
||||||
|
};
|
||||||
|
|
||||||
[state] bool force_next_check;
|
[state] bool force_next_check;
|
||||||
[state] int acknowledgement (AcknowledgementRaw) {
|
[state] int acknowledgement (AcknowledgementRaw) {
|
||||||
|
@ -192,7 +192,7 @@ int Host::GetSeverity() const
|
|||||||
return severity;
|
return severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Host::IsStateOK(ServiceState state)
|
bool Host::IsStateOK(ServiceState state) const
|
||||||
{
|
{
|
||||||
return Host::CalculateState(state) == HostUp;
|
return Host::CalculateState(state) == HostUp;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
HostState GetLastHardState() const override;
|
HostState GetLastHardState() const override;
|
||||||
int GetSeverity() const override;
|
int GetSeverity() const override;
|
||||||
|
|
||||||
bool IsStateOK(ServiceState state) override;
|
bool IsStateOK(ServiceState state) const override;
|
||||||
void SaveLastState(ServiceState state, double timestamp) override;
|
void SaveLastState(ServiceState state, double timestamp) override;
|
||||||
|
|
||||||
static HostState StateFromString(const String& state);
|
static HostState StateFromString(const String& state);
|
||||||
|
@ -133,7 +133,7 @@ int Service::GetSeverity() const
|
|||||||
return severity;
|
return severity;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::IsStateOK(ServiceState state)
|
bool Service::IsStateOK(ServiceState state) const
|
||||||
{
|
{
|
||||||
return state == ServiceOK;
|
return state == ServiceOK;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Value *result) const override;
|
bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Value *result) const override;
|
||||||
|
|
||||||
bool IsStateOK(ServiceState state) override;
|
bool IsStateOK(ServiceState state) const override;
|
||||||
void SaveLastState(ServiceState state, double timestamp) override;
|
void SaveLastState(ServiceState state, double timestamp) override;
|
||||||
|
|
||||||
static ServiceState StateFromString(const String& state);
|
static ServiceState StateFromString(const String& state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user