mirror of https://github.com/Icinga/icinga2.git
Flapping: Allow to ignore states in flapping calculation
This commit is contained in:
parent
fb6f618f82
commit
e060995fd8
|
@ -468,6 +468,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
|
||||
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
|
||||
[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.
|
||||
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\_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`.
|
||||
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.
|
||||
|
@ -721,6 +722,7 @@ Configuration Attributes:
|
|||
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\_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`.
|
||||
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`.
|
||||
|
|
|
@ -369,7 +369,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
|||
|
||||
bool was_flapping = IsFlapping();
|
||||
|
||||
UpdateFlappingStatus(old_state != cr->GetState());
|
||||
UpdateFlappingStatus(cr->GetState());
|
||||
|
||||
bool is_flapping = IsFlapping();
|
||||
|
||||
|
|
|
@ -36,11 +36,22 @@ private:
|
|||
T m_Data{0};
|
||||
};
|
||||
|
||||
void Checkable::UpdateFlappingStatus(bool stateChange)
|
||||
void Checkable::UpdateFlappingStatus(ServiceState newState)
|
||||
{
|
||||
Bitset<unsigned long> stateChangeBuf = GetFlappingBuffer();
|
||||
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);
|
||||
oldestIndex = (oldestIndex + 1) % 20;
|
||||
|
||||
|
@ -85,3 +96,19 @@ bool Checkable::IsFlapping() const
|
|||
else
|
||||
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());
|
||||
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&, double, const MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
|
||||
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlappingChange;
|
||||
|
@ -36,6 +45,13 @@ Checkable::Checkable()
|
|||
SetSchedulingOffset(Utility::Random());
|
||||
}
|
||||
|
||||
void Checkable::OnConfigLoaded()
|
||||
{
|
||||
ObjectImpl<Checkable>::OnConfigLoaded();
|
||||
|
||||
SetFlappingIgnoreStatesFilter(FilterArrayToInt(GetFlappingIgnoreStates(), m_FlappingStateFilterMap, ~0));
|
||||
}
|
||||
|
||||
void Checkable::OnAllConfigLoaded()
|
||||
{
|
||||
ObjectImpl<Checkable>::OnAllConfigLoaded();
|
||||
|
|
|
@ -39,6 +39,17 @@ enum CheckableType
|
|||
CheckableService
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup icinga
|
||||
*/
|
||||
enum FlappingStateFilter
|
||||
{
|
||||
FlappingStateFilterOk = 1,
|
||||
FlappingStateFilterWarning = 2,
|
||||
FlappingStateFilterCritical = 4,
|
||||
FlappingStateFilterUnknown = 8,
|
||||
};
|
||||
|
||||
class CheckCommand;
|
||||
class EventCommand;
|
||||
class Dependency;
|
||||
|
@ -183,6 +194,7 @@ public:
|
|||
|
||||
protected:
|
||||
void Start(bool runtimeCreated) override;
|
||||
void OnConfigLoaded() override;
|
||||
void OnAllConfigLoaded() override;
|
||||
|
||||
private:
|
||||
|
@ -222,7 +234,10 @@ private:
|
|||
void GetAllChildrenInternal(std::set<Checkable::Ptr>& children, int level = 0) const;
|
||||
|
||||
/* 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; }}}
|
||||
};
|
||||
|
||||
[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] double flapping_threshold_low {
|
||||
|
@ -163,6 +166,9 @@ abstract class Checkable : CustomVarObject
|
|||
};
|
||||
[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_index;
|
||||
[state, protected] bool flapping;
|
||||
|
|
Loading…
Reference in New Issue