In this recipe, we'll learn how to adjust the percentage thresholds for a host's or service's flap detection. This means that we can adjust how frequently a host or service has to change its state within its last 21 checks before Nagios Core concludes it's flapping and suppresses notifications until its state becomes stable again.
You should have a Nagios Core 4.0 or newer server with at least one host and one service configured already. You should also have access to a working web interface for the Nagios Core server.
You should be familiar with the way hosts and services change their state as a result of their checks and the different states corresponding to hosts and services, to understand the basics of how flap detection works. Flap detection should also already be enabled and working for the appropriate hosts and services.
We can adjust the thresholds for flap detection for a specific host or service as follows:
/usr/local/nagios/etc/objects
:# cd /usr/local/nagios/etc/objects
# vi sparta.example.net.cfg
low_flap_threshold
and/or high_flap_threshold
values to appropriate percentages:define host { ... high_flap_threshold 50.0 low_flap_threshold 25.0 } define service { ... high_flap_threshold 45.0 low_flap_threshold 20.0 }
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg # /etc/init.d/nagios reload
With this done, the flapping thresholds for the host or service should be changed appropriately for future checks.
The preceding configuration changes include the following directives:
high_flap_threshold
: This refers to a host or service that changes its state a certain percentage of the time must exceed this percentage threshold before it is determined to be flappinglow_flap_threshold
: If a host or service is already in the flapping state, its state change percentage must fall to this amount or fall fall below this percentage threshold before the flapping state will endFor a detailed breakdown of how the state change percentage is calculated, refer to the Nagios Core 4.0 documentation online at http://nagios.sourceforge.net/docs/nagioscore/4/en/flapping.html.
If appropriate, we can also set a global default for hosts and services' flap thresholds with the following directives in /usr/local/nagios/etc/nagios.cfg
. A set of possible values for these attributes might be:
low_service_flap_threshold=5.0 high_service_flap_threshold=20.0 low_host_flap_threshold=5.0 high_host_flap_threshold=20.0
These values correspond to percentages of state changes in the same way that the per-host and per-service configurations do.
Note that there are separate directives for hosts and services in this case. These values are also overridden if you specify thresholds for a particular service or host, as we did in this recipe.
18.189.2.122