mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
Merge pull request #8600 from Icinga/feature/flapping-ignore-unknown
Flapping: Allow to ignore states in flapping detection
This commit is contained in:
commit
124f98eed4
@ -481,6 +481,8 @@ when a [host](09-object-types.md#objecttype-host) or [service](09-object-types.m
|
|||||||
The default thresholds are 30% for high and 25% for low. If the computed flapping value exceeds the high threshold a
|
The default thresholds are 30% for high and 25% for low. If the computed flapping value exceeds the high threshold a
|
||||||
host or service is considered flapping until it drops below the low flapping threshold.
|
host or service is considered flapping until it drops below the low flapping threshold.
|
||||||
|
|
||||||
|
The attribute `flapping_ignore_states` allows to ignore state changes to specified states during the flapping calculation.
|
||||||
|
|
||||||
`FlappingStart` and `FlappingEnd` notifications will be sent out accordingly, if configured. See the chapter on
|
`FlappingStart` and `FlappingEnd` notifications will be sent out accordingly, if configured. See the chapter on
|
||||||
[notifications](alert-notifications) for details
|
[notifications](alert-notifications) for details
|
||||||
|
|
||||||
|
@ -359,6 +359,7 @@ Configuration Attributes:
|
|||||||
event\_command | Object name | **Optional.** The name of an event command that should be executed every time the host's state changes or the host is in a `SOFT` state.
|
event\_command | Object name | **Optional.** The name of an event command that should be executed every time the host's state changes or the host is in a `SOFT` state.
|
||||||
flapping\_threshold\_high | Number | **Optional.** Flapping upper bound in percent for a host to be considered flapping. Default `30.0`
|
flapping\_threshold\_high | Number | **Optional.** Flapping upper bound in percent for a host to be considered flapping. Default `30.0`
|
||||||
flapping\_threshold\_low | Number | **Optional.** Flapping lower bound in percent for a host to be considered not flapping. Default `25.0`
|
flapping\_threshold\_low | Number | **Optional.** Flapping lower bound in percent for a host to be considered not flapping. Default `25.0`
|
||||||
|
flapping\_ignore\_states | Array | **Optional.** A list of states that should be ignored during flapping calculation. By default no state is ignored.
|
||||||
volatile | Boolean | **Optional.** Treat all state changes as HARD changes. See [here](08-advanced-topics.md#volatile-services-hosts) for details. Defaults to `false`.
|
volatile | Boolean | **Optional.** Treat all state changes as HARD changes. See [here](08-advanced-topics.md#volatile-services-hosts) for details. Defaults to `false`.
|
||||||
zone | Object name | **Optional.** The zone this object is a member of. Please read the [distributed monitoring](06-distributed-monitoring.md#distributed-monitoring) chapter for details.
|
zone | Object name | **Optional.** The zone this object is a member of. Please read the [distributed monitoring](06-distributed-monitoring.md#distributed-monitoring) chapter for details.
|
||||||
command\_endpoint | Object name | **Optional.** The endpoint where commands are executed on.
|
command\_endpoint | Object name | **Optional.** The endpoint where commands are executed on.
|
||||||
@ -723,6 +724,7 @@ Configuration Attributes:
|
|||||||
enable\_flapping | Boolean | **Optional.** Whether flap detection is enabled. Defaults to `false`.
|
enable\_flapping | Boolean | **Optional.** Whether flap detection is enabled. Defaults to `false`.
|
||||||
flapping\_threshold\_high | Number | **Optional.** Flapping upper bound in percent for a service to be considered flapping. `30.0`
|
flapping\_threshold\_high | Number | **Optional.** Flapping upper bound in percent for a service to be considered flapping. `30.0`
|
||||||
flapping\_threshold\_low | Number | **Optional.** Flapping lower bound in percent for a service to be considered not flapping. `25.0`
|
flapping\_threshold\_low | Number | **Optional.** Flapping lower bound in percent for a service to be considered not flapping. `25.0`
|
||||||
|
flapping\_ignore\_states | Array | **Optional.** A list of states that should be ignored during flapping calculation. By default no state is ignored.
|
||||||
enable\_perfdata | Boolean | **Optional.** Whether performance data processing is enabled. Defaults to `true`.
|
enable\_perfdata | Boolean | **Optional.** Whether performance data processing is enabled. Defaults to `true`.
|
||||||
event\_command | Object name | **Optional.** The name of an event command that should be executed every time the service's state changes or the service is in a `SOFT` state.
|
event\_command | Object name | **Optional.** The name of an event command that should be executed every time the service's state changes or the service is in a `SOFT` state.
|
||||||
volatile | Boolean | **Optional.** Treat all state changes as HARD changes. See [here](08-advanced-topics.md#volatile-services-hosts) for details. Defaults to `false`.
|
volatile | Boolean | **Optional.** Treat all state changes as HARD changes. See [here](08-advanced-topics.md#volatile-services-hosts) for details. Defaults to `false`.
|
||||||
|
@ -383,7 +383,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
|||||||
|
|
||||||
bool was_flapping = IsFlapping();
|
bool was_flapping = IsFlapping();
|
||||||
|
|
||||||
UpdateFlappingStatus(old_state != cr->GetState());
|
UpdateFlappingStatus(cr->GetState());
|
||||||
|
|
||||||
bool is_flapping = IsFlapping();
|
bool is_flapping = IsFlapping();
|
||||||
|
|
||||||
|
@ -36,11 +36,22 @@ private:
|
|||||||
T m_Data{0};
|
T m_Data{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
void Checkable::UpdateFlappingStatus(bool stateChange)
|
void Checkable::UpdateFlappingStatus(ServiceState newState)
|
||||||
{
|
{
|
||||||
Bitset<unsigned long> stateChangeBuf = GetFlappingBuffer();
|
Bitset<unsigned long> stateChangeBuf = GetFlappingBuffer();
|
||||||
int oldestIndex = GetFlappingIndex();
|
int oldestIndex = GetFlappingIndex();
|
||||||
|
|
||||||
|
ServiceState lastState = GetFlappingLastState();
|
||||||
|
bool stateChange = false;
|
||||||
|
|
||||||
|
int stateFilter = GetFlappingIgnoreStatesFilter();
|
||||||
|
|
||||||
|
/* Only count as state change if no state filter is set or the new state isn't filtered out */
|
||||||
|
if (stateFilter == -1 || !(ServiceStateToFlappingFilter(newState) & stateFilter)) {
|
||||||
|
stateChange = newState != lastState;
|
||||||
|
SetFlappingLastState(newState);
|
||||||
|
}
|
||||||
|
|
||||||
stateChangeBuf.Modify(oldestIndex, stateChange);
|
stateChangeBuf.Modify(oldestIndex, stateChange);
|
||||||
oldestIndex = (oldestIndex + 1) % 20;
|
oldestIndex = (oldestIndex + 1) % 20;
|
||||||
|
|
||||||
@ -85,3 +96,19 @@ bool Checkable::IsFlapping() const
|
|||||||
else
|
else
|
||||||
return GetFlapping();
|
return GetFlapping();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Checkable::ServiceStateToFlappingFilter(ServiceState state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case ServiceOK:
|
||||||
|
return StateFilterOK;
|
||||||
|
case ServiceWarning:
|
||||||
|
return StateFilterWarning;
|
||||||
|
case ServiceCritical:
|
||||||
|
return StateFilterCritical;
|
||||||
|
case ServiceUnknown:
|
||||||
|
return StateFilterUnknown;
|
||||||
|
default:
|
||||||
|
VERIFY(!"Invalid state type.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -15,6 +15,15 @@ using namespace icinga;
|
|||||||
REGISTER_TYPE_WITH_PROTOTYPE(Checkable, Checkable::GetPrototype());
|
REGISTER_TYPE_WITH_PROTOTYPE(Checkable, Checkable::GetPrototype());
|
||||||
INITIALIZE_ONCE(&Checkable::StaticInitialize);
|
INITIALIZE_ONCE(&Checkable::StaticInitialize);
|
||||||
|
|
||||||
|
const std::map<String, int> Checkable::m_FlappingStateFilterMap ({
|
||||||
|
{"OK", FlappingStateFilterOk},
|
||||||
|
{"Warning", FlappingStateFilterWarning},
|
||||||
|
{"Critical", FlappingStateFilterCritical},
|
||||||
|
{"Unknown", FlappingStateFilterUnknown},
|
||||||
|
{"Up", FlappingStateFilterOk},
|
||||||
|
{"Down", FlappingStateFilterCritical},
|
||||||
|
});
|
||||||
|
|
||||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, bool, double, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
|
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String&, AcknowledgementType, bool, bool, double, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementSet;
|
||||||
boost::signals2::signal<void (const Checkable::Ptr&, const String&, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
boost::signals2::signal<void (const Checkable::Ptr&, const String&, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
||||||
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlappingChange;
|
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlappingChange;
|
||||||
@ -39,6 +48,13 @@ Checkable::Checkable()
|
|||||||
SetSchedulingOffset(Utility::Random());
|
SetSchedulingOffset(Utility::Random());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Checkable::OnConfigLoaded()
|
||||||
|
{
|
||||||
|
ObjectImpl<Checkable>::OnConfigLoaded();
|
||||||
|
|
||||||
|
SetFlappingIgnoreStatesFilter(FilterArrayToInt(GetFlappingIgnoreStates(), m_FlappingStateFilterMap, ~0));
|
||||||
|
}
|
||||||
|
|
||||||
void Checkable::OnAllConfigLoaded()
|
void Checkable::OnAllConfigLoaded()
|
||||||
{
|
{
|
||||||
ObjectImpl<Checkable>::OnAllConfigLoaded();
|
ObjectImpl<Checkable>::OnAllConfigLoaded();
|
||||||
|
@ -41,6 +41,17 @@ enum CheckableType
|
|||||||
CheckableService
|
CheckableService
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup icinga
|
||||||
|
*/
|
||||||
|
enum FlappingStateFilter
|
||||||
|
{
|
||||||
|
FlappingStateFilterOk = 1,
|
||||||
|
FlappingStateFilterWarning = 2,
|
||||||
|
FlappingStateFilterCritical = 4,
|
||||||
|
FlappingStateFilterUnknown = 8,
|
||||||
|
};
|
||||||
|
|
||||||
class CheckCommand;
|
class CheckCommand;
|
||||||
class EventCommand;
|
class EventCommand;
|
||||||
class Dependency;
|
class Dependency;
|
||||||
@ -186,6 +197,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Start(bool runtimeCreated) override;
|
void Start(bool runtimeCreated) override;
|
||||||
|
void OnConfigLoaded() override;
|
||||||
void OnAllConfigLoaded() override;
|
void OnAllConfigLoaded() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -226,7 +238,10 @@ private:
|
|||||||
void GetAllChildrenInternal(std::set<Checkable::Ptr>& children, int level = 0) const;
|
void GetAllChildrenInternal(std::set<Checkable::Ptr>& children, int level = 0) const;
|
||||||
|
|
||||||
/* Flapping */
|
/* Flapping */
|
||||||
void UpdateFlappingStatus(bool stateChange);
|
static const std::map<String, int> m_FlappingStateFilterMap;
|
||||||
|
|
||||||
|
void UpdateFlappingStatus(ServiceState newState);
|
||||||
|
static int ServiceStateToFlappingFilter(ServiceState state);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,9 @@ abstract class Checkable : CustomVarObject
|
|||||||
default {{{ return true; }}}
|
default {{{ return true; }}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[config] array(String) flapping_ignore_states;
|
||||||
|
[no_user_view, no_user_modify] int flapping_ignore_states_filter_real (FlappingIgnoreStatesFilter);
|
||||||
|
|
||||||
[config, deprecated] double flapping_threshold;
|
[config, deprecated] double flapping_threshold;
|
||||||
|
|
||||||
[config] double flapping_threshold_low {
|
[config] double flapping_threshold_low {
|
||||||
@ -163,6 +166,9 @@ abstract class Checkable : CustomVarObject
|
|||||||
};
|
};
|
||||||
[state] Timestamp flapping_last_change;
|
[state] Timestamp flapping_last_change;
|
||||||
|
|
||||||
|
[state, enum, no_user_view, no_user_modify] ServiceState flapping_last_state {
|
||||||
|
default {{{ return ServiceUnknown; }}}
|
||||||
|
};
|
||||||
[state, no_user_view, no_user_modify] int flapping_buffer;
|
[state, no_user_view, no_user_modify] int flapping_buffer;
|
||||||
[state, no_user_view, no_user_modify] int flapping_index;
|
[state, no_user_view, no_user_modify] int flapping_index;
|
||||||
[state, protected] bool flapping;
|
[state, protected] bool flapping;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user