]> granicus.if.org Git - icinga2/commitdiff
Implement Service::GetFlappingCurrent().
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 1 Jul 2013 12:39:43 +0000 (14:39 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 1 Jul 2013 12:39:43 +0000 (14:39 +0200)
lib/icinga/service-flapping.cpp
lib/icinga/service.h

index 512b48cdb59f4e0a1a2ee75e63d4af58d3f85596..1c353d97f3ab00a4be0c91474361e17ebe8362f7 100644 (file)
@@ -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();
 }
index 939c344ea530dd3dbb80d366a73114253acccc43..824036f6bdd558f428c6cc258c632313a178c1c4 100644 (file)
@@ -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;