diff --git a/lib/icinga/service-flapping.cpp b/lib/icinga/service-flapping.cpp index 512b48cdb..1c353d97f 100644 --- a/lib/icinga/service-flapping.cpp +++ b/lib/icinga/service-flapping.cpp @@ -32,6 +32,14 @@ using namespace icinga; #define FLAPPING_INTERVAL (30 * 60) +double Service::GetFlappingCurrent(void) const +{ + if (m_FlappingNegative.IsEmpty() || m_FlappingPositive.IsEmpty()) + return 0; + + return 100 * m_FlappingPositive / (m_FlappingPositive + m_FlappingNegative); +} + double Service::GetFlappingThreshold(void) const { if (m_FlappingThreshold.IsEmpty()) @@ -105,14 +113,5 @@ void Service::UpdateFlappingStatus(bool stateChange) bool Service::IsFlapping(void) const { - double threshold = 20; - - if (!m_FlappingThreshold.IsEmpty()) - threshold = m_FlappingThreshold; - - if (m_FlappingNegative.IsEmpty() || m_FlappingPositive.IsEmpty()) - return false; - - return (m_FlappingPositive > threshold * (m_FlappingPositive + m_FlappingNegative) / 100); - + return GetFlappingCurrent() > GetFlappingThreshold(); } diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 939c344ea..824036f6b 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -269,6 +269,7 @@ public: bool GetEnableFlapping(void) const; void SetEnableFlapping(bool enabled); + double GetFlappingCurrent(void) const; double GetFlappingThreshold(void) const; bool IsFlapping(void) const;