From 896d447e11754e56d1ce9a6e251036f9f9f39089 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 9 Apr 2019 11:34:59 +0200 Subject: [PATCH] Add Checkable#problem and #handled --- lib/icinga/checkable.cpp | 10 ++++++++++ lib/icinga/checkable.hpp | 2 ++ lib/icinga/checkable.ti | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/lib/icinga/checkable.cpp b/lib/icinga/checkable.cpp index 227ce4ccc..1fe6a3d97 100644 --- a/lib/icinga/checkable.cpp +++ b/lib/icinga/checkable.cpp @@ -144,6 +144,16 @@ 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) { if (!downtime->GetFixed()) diff --git a/lib/icinga/checkable.hpp b/lib/icinga/checkable.hpp index 7a0623ac4..44cfaad49 100644 --- a/lib/icinga/checkable.hpp +++ b/lib/icinga/checkable.hpp @@ -86,6 +86,8 @@ public: int GetSeverity() const override; bool GetReachable() const override; + bool GetProblem() const override; + bool GetHandled() const override; /* Checks */ intrusive_ptr GetCheckCommand() const; diff --git a/lib/icinga/checkable.ti b/lib/icinga/checkable.ti index 0921f6f2f..286e4b8f6 100644 --- a/lib/icinga/checkable.ti +++ b/lib/icinga/checkable.ti @@ -126,6 +126,12 @@ abstract class Checkable : CustomVarObject [no_storage] bool reachable { get; }; + [no_storage] bool problem { + get; + }; + [no_storage] bool handled { + get; + }; [state] bool force_next_check; [state] int acknowledgement (AcknowledgementRaw) {