mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
flapping: fix division by 0, add compat status, extcmds
and some debug output. refs #4360 refs #2711
This commit is contained in:
parent
bd6e5d11ac
commit
ce9c390ed9
@ -413,6 +413,9 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
|
|||||||
<< "\t" << "notifications_enabled=" << (service->GetEnableNotifications() ? 1 : 0) << "\n"
|
<< "\t" << "notifications_enabled=" << (service->GetEnableNotifications() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "active_checks_enabled=" << (service->GetEnableActiveChecks() ? 1 : 0) <<"\n"
|
<< "\t" << "active_checks_enabled=" << (service->GetEnableActiveChecks() ? 1 : 0) <<"\n"
|
||||||
<< "\t" << "passive_checks_enabled=" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
<< "\t" << "passive_checks_enabled=" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
||||||
|
<< "\t" << "flap_detection_enabled=" << "\t" << (service->GetEnableFlapping() ? 1 : 0) << "\n"
|
||||||
|
<< "\t" << "is_flapping=" << "\t" << (service->IsFlapping() ? 1 : 0) << "\n"
|
||||||
|
<< "\t" << "percent_state_change=" << "\t" << Convert::ToString(service->GetFlappingCurrent()) << "\n"
|
||||||
<< "\t" << "problem_has_been_acknowledged=" << (service->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
|
<< "\t" << "problem_has_been_acknowledged=" << (service->GetAcknowledgement() != AcknowledgementNone ? 1 : 0) << "\n"
|
||||||
<< "\t" << "acknowledgement_type=" << static_cast<int>(service->GetAcknowledgement()) << "\n"
|
<< "\t" << "acknowledgement_type=" << static_cast<int>(service->GetAcknowledgement()) << "\n"
|
||||||
<< "\t" << "acknowledgement_end_time=" << service->GetAcknowledgementExpiry() << "\n"
|
<< "\t" << "acknowledgement_end_time=" << service->GetAcknowledgementExpiry() << "\n"
|
||||||
|
@ -118,6 +118,10 @@ void ExternalCommandProcessor::Initialize(void)
|
|||||||
RegisterCommand("ACKNOWLEDGE_HOST_PROBLEM", &ExternalCommandProcessor::AcknowledgeHostProblem);
|
RegisterCommand("ACKNOWLEDGE_HOST_PROBLEM", &ExternalCommandProcessor::AcknowledgeHostProblem);
|
||||||
RegisterCommand("ACKNOWLEDGE_HOST_PROBLEM_EXPIRE", &ExternalCommandProcessor::AcknowledgeHostProblemExpire);
|
RegisterCommand("ACKNOWLEDGE_HOST_PROBLEM_EXPIRE", &ExternalCommandProcessor::AcknowledgeHostProblemExpire);
|
||||||
RegisterCommand("REMOVE_HOST_ACKNOWLEDGEMENT", &ExternalCommandProcessor::RemoveHostAcknowledgement);
|
RegisterCommand("REMOVE_HOST_ACKNOWLEDGEMENT", &ExternalCommandProcessor::RemoveHostAcknowledgement);
|
||||||
|
RegisterCommand("DISABLE_HOST_FLAP_DETECTION", &ExternalCommandProcessor::DisableHostFlapping);
|
||||||
|
RegisterCommand("ENABLE_HOST_FLAP_DETECTION", &ExternalCommandProcessor::EnableHostFlapping);
|
||||||
|
RegisterCommand("DISABLE_SVC_FLAP_DETECTION", &ExternalCommandProcessor::DisableSvcFlapping);
|
||||||
|
RegisterCommand("ENABLE_SVC_FLAP_DETECTION", &ExternalCommandProcessor::EnableSvcFlapping);
|
||||||
RegisterCommand("ENABLE_HOSTGROUP_SVC_CHECKS", &ExternalCommandProcessor::EnableHostgroupSvcChecks);
|
RegisterCommand("ENABLE_HOSTGROUP_SVC_CHECKS", &ExternalCommandProcessor::EnableHostgroupSvcChecks);
|
||||||
RegisterCommand("DISABLE_HOSTGROUP_SVC_CHECKS", &ExternalCommandProcessor::DisableHostgroupSvcChecks);
|
RegisterCommand("DISABLE_HOSTGROUP_SVC_CHECKS", &ExternalCommandProcessor::DisableHostgroupSvcChecks);
|
||||||
RegisterCommand("ENABLE_SERVICEGROUP_SVC_CHECKS", &ExternalCommandProcessor::EnableServicegroupSvcChecks);
|
RegisterCommand("ENABLE_SERVICEGROUP_SVC_CHECKS", &ExternalCommandProcessor::EnableServicegroupSvcChecks);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
||||||
|
#include "base/convert.h"
|
||||||
#include <boost/smart_ptr/make_shared.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/exception/diagnostic_information.hpp>
|
#include <boost/exception/diagnostic_information.hpp>
|
||||||
@ -460,6 +461,13 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
|
|||||||
|
|
||||||
olock.Unlock();
|
olock.Unlock();
|
||||||
|
|
||||||
|
Log(LogDebug, "icinga", "Flapping: Service " +
|
||||||
|
GetName() + " was: " +
|
||||||
|
Convert::ToString(was_flapping) + " is: " +
|
||||||
|
Convert::ToString(was_flapping) + " threshold: " +
|
||||||
|
Convert::ToString(GetFlappingThreshold()) + "% current: " +
|
||||||
|
Convert::ToString(GetFlappingCurrent()) + "%.");
|
||||||
|
|
||||||
/* Flush the object so other instances see the service's
|
/* Flush the object so other instances see the service's
|
||||||
* new state when they receive the CheckResult message */
|
* new state when they receive the CheckResult message */
|
||||||
Flush();
|
Flush();
|
||||||
@ -495,6 +503,8 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
|
|||||||
rm.SetParams(params);
|
rm.SetParams(params);
|
||||||
|
|
||||||
EndpointManager::GetInstance()->SendMulticastMessage(rm);
|
EndpointManager::GetInstance()->SendMulticastMessage(rm);
|
||||||
|
|
||||||
|
Log(LogDebug, "icinga", "Flapping: Service " + GetName() + " started flapping (" + Convert::ToString(GetFlappingThreshold()) + "% < " + Convert::ToString(GetFlappingCurrent()) + "%).");
|
||||||
}
|
}
|
||||||
else if (was_flapping && !is_flapping) {
|
else if (was_flapping && !is_flapping) {
|
||||||
RequestNotifications(NotificationFlappingEnd, cr);
|
RequestNotifications(NotificationFlappingEnd, cr);
|
||||||
@ -509,6 +519,8 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
|
|||||||
rm.SetParams(params);
|
rm.SetParams(params);
|
||||||
|
|
||||||
EndpointManager::GetInstance()->SendMulticastMessage(rm);
|
EndpointManager::GetInstance()->SendMulticastMessage(rm);
|
||||||
|
|
||||||
|
Log(LogDebug, "icinga", "Flapping: Service " + GetName() + " stopped flapping (" + Convert::ToString(GetFlappingThreshold()) + "% >= " + Convert::ToString(GetFlappingCurrent()) + "%).");
|
||||||
}
|
}
|
||||||
else if (send_notification)
|
else if (send_notification)
|
||||||
RequestNotifications(recovery ? NotificationRecovery : NotificationProblem, cr);
|
RequestNotifications(recovery ? NotificationRecovery : NotificationProblem, cr);
|
||||||
|
@ -38,6 +38,9 @@ double Service::GetFlappingCurrent(void) const
|
|||||||
if (m_FlappingNegative.IsEmpty() || m_FlappingPositive.IsEmpty())
|
if (m_FlappingNegative.IsEmpty() || m_FlappingPositive.IsEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if ((m_FlappingPositive + m_FlappingNegative) <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 100 * m_FlappingPositive / (m_FlappingPositive + m_FlappingNegative);
|
return 100 * m_FlappingPositive / (m_FlappingPositive + m_FlappingNegative);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user