From 4ab9d2604ffb19bdba3cf274752d7bc8e220e03f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 13 Jun 2013 12:24:20 +0200 Subject: [PATCH] Implement volatile services Fixes #3593 --- lib/icinga/service-check.cpp | 3 +++ lib/icinga/service.cpp | 9 +++++++++ lib/icinga/service.h | 3 +++ 3 files changed, 15 insertions(+) diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp index 48e8823a180..4270d8a27d7 100644 --- a/lib/icinga/service-check.cpp +++ b/lib/icinga/service-check.cpp @@ -402,6 +402,9 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr) if (old_state != GetState() && old_stateType == StateTypeHard && GetStateType() == StateTypeHard) hardChange = true; + if (IsVolatile()) + hardChange = true; + if (hardChange) SetLastHardStateChange(now); diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index e257eec92a6..4bd5aeda1a2 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -52,6 +52,7 @@ Service::Service(const Dictionary::Ptr& serializedObject) RegisterAttribute("checkers", Attribute_Config, &m_Checkers); RegisterAttribute("event_command", Attribute_Config, &m_EventCommand); + RegisterAttribute("volatile", Attribute_Config, &m_Volatile); RegisterAttribute("next_check", Attribute_Replicated, &m_NextCheck); RegisterAttribute("current_checker", Attribute_Replicated, &m_CurrentChecker); @@ -223,6 +224,14 @@ bool Service::IsReachable(void) const return true; } +bool Service::IsVolatile(void) const +{ + if (m_Volatile.IsEmpty()) + return false; + + return m_Volatile; +} + AcknowledgementType Service::GetAcknowledgement(void) { ASSERT(OwnsLock()); diff --git a/lib/icinga/service.h b/lib/icinga/service.h index d6b0ab02f3f..0db3e4dd19c 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -94,6 +94,8 @@ class I2_ICINGA_API Service : public DynamicObject, public MacroResolver std::set GetParentHosts(void) const; std::set GetParentServices(void) const; + bool IsVolatile(void) const; + bool IsReachable(void) const; AcknowledgementType GetAcknowledgement(void); @@ -261,6 +263,7 @@ class I2_ICINGA_API Service : public DynamicObject, public MacroResolver Attribute m_Acknowledgement; Attribute m_AcknowledgementExpiry; Attribute m_HostName; + Attribute m_Volatile; /* Checks */ Attribute m_CheckCommand;