Implement Service::GetFlappingCurrent().

This commit is contained in:
Gunnar Beutner 2013-07-01 14:39:43 +02:00
parent ff6383873f
commit bdd0ee013c
2 changed files with 10 additions and 10 deletions

View 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();
}

View 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;