lib/sensu/server/process.rb
# Determine if a check state is flapping, rapidly changing
# between an OK and non-OK state. Flap detection is only done
# for checks that have defined low and hight flap detection
# thresholds, `:low_flap_threshold` and `:high_flap_threshold`.
# The `check_history()` method provides the check history and
# more importantly the total state change precentage value that
# is compared with the configured thresholds defined in the
# check data. If a check hasn't been flapping, the
# `:total_state_change` must be equal to or higher than the
# `:high_flap_threshold` to be changed to flapping. If a check
# has been flapping, the `:total_state_change` must be equal to
# or lower than the `:low_flap_threshold` to no longer be
# flapping. This method uses the same algorithm as Nagios:
# http://nagios.sourceforge.net/docs/3_0/flapping.html
#
# @param stored_event [Hash]
# @param check [Hash]
# @return [TrueClass, FalseClass]
Determine if a check state is flapping, rapidly changing
between an OK and non-OK state. Flap detection is only done
for checks that have defined low and hight flap detection
thresholds, `:low_flap_threshold` and `:high_flap_threshold`.
The `check_history()` method provides the check history and
more importantly the total state change precentage value that
is compared with the configured thresholds defined in the
check data. If a check hasn't been flapping, the
`:total_state_change` must be equal to or higher than the
`:high_flap_threshold` to be changed to flapping. If a check
has been flapping, the `:total_state_change` must be equal to
or lower than the `:low_flap_threshold` to no longer be
flapping.
Determine if a check state is flapping rapidly changing between an OK and non - OK state . Flap detection is only done for checks that have defined low and hight flap detection thresholds ` : low_flap_threshold ` and ` : high_flap_threshold ` . The ` check_history () ` method provides the check history and more importantly the total state change precentage value that is compared with the configured thresholds defined in the check data . If a check hasn ' t been flapping the ` : total_state_change ` must be equal to or higher than the ` : high_flap_threshold ` to be changed to flapping . If a check has been flapping the ` : total_state_change ` must be equal to or lower than the ` : low_flap_threshold ` to no longer be flapping .
def check_flapping?(stored_event, check)
        if check.has_key?(:low_flap_threshold) && check.has_key?(:high_flap_threshold)
          if check[:low_flap_threshold].is_a?(Integer) && check[:high_flap_threshold].is_a?(Integer)
            was_flapping = stored_event && stored_event[:action] == EVENT_FLAPPING_ACTION
            if was_flapping
              check[:total_state_change] > check[:low_flap_threshold]
            else
              check[:total_state_change] >= check[:high_flap_threshold]
            end
          else
            details = {:check => check}
            details[:client] = stored_event[:client] if stored_event
            @logger.error("invalid check flap thresholds", details)
            false
          end
        else
          false
        end
      end
def check_flapping? ( stored_event , check ) if check . has_key? ( :low_flap_threshold ) && check . has_key? ( :high_flap_threshold ) if check [ :low_flap_threshold ] . is_a? ( Integer ) && check [ :high_flap_threshold ] . is_a? ( Integer ) was_flapping = stored_event && stored_event [ :action ] == EVENT_FLAPPING_ACTION if was_flapping check [ :total_state_change ] > check [ :low_flap_threshold ] else check [ :total_state_change ] >= check [ :high_flap_threshold ] end else details = { :check => check } details [ :client ] = stored_event [ :client ] if stored_event @logger . error ( "invalid check flap thresholds" , details ) false end else false end end
Determine if a check state is flapping, rapidly changing
between an OK and non-OK state.
Determine if a check state is flapping rapidly changing between an OK and non - OK state .
None
TrueClass, FalseClass
stored_event
check
None