In this recipe, we'll learn how to use Nagios Core's state flapping detection and handling techniques to avoid sending excessive notifications when a host or service changes its state too frequently. This is useful in circumstances where a host or service is changing between OK
to WARNING
to CRITICAL
states too frequently within the last 21 checks; if the percentage of state changes is too high, then Nagios Core will suppress further notifications and add a comment to the host or service, showing that it is flapping.
Flap detection is normally enabled by default in Nagios Core and it is part of the recommended generic-host
host template and the generic-service
service template. It's therefore likely that it's already enabled on most servers and we only need to check that it's still working.