lib/sensu/extensions/check-deps.rb
# Determine if an event exists for any of the check
# dependencies declared in the event data, specified in array,
# check `dependencies`. A check dependency can be a check
# executed by the same Sensu client (eg. `check_app`), a
# client/check pair (eg.`i-424242/check_mysql`), or a
# subscription/check pair (eg. `subscription:mysql/check_mysql`).
#
# @param event [Hash]
# @return [Boolean]
Determine if an event exists for any of the check
dependencies declared in the event data, specified in array,
check `dependencies`. A check dependency can be a check
executed by the same Sensu client , a
client/check pair , or a
subscription/check pair .
Determine if an event exists for any of the check dependencies declared in the event data specified in array check ` dependencies ` . A check dependency can be a check executed by the same Sensu client a client / check pair or a subscription / check pair .
def dependency_events_exist?(event)
              dependencies_string = event[:check][:dependencies][:dependency]
              dependencies_array = dependencies_string.split(" ")
              dependencies_array ||= []
              if dependencies_array.is_a?(Array)
                dependencies_array.any? do |dependency|
                  begin
                    check_name, entity = dependency.split("/").reverse
                    if entity =~ /^subscription:.*$/
                      subscription_name = entity.split(":")[1]
                      subscription_event_exists?(subscription_name, check_name)
                    else
                      client_name = entity
                      client_name ||= event[:client][:name]
                      client_event_exists?(client_name, check_name)
                    end
                  rescue => error
                    @logger.error("failed to query api for a check dependency event", :error => error)
                    false
                  end
                end
              else
                false
              end
            end
def dependency_events_exist? ( event ) dependencies_string = event [ :check ] [ :dependencies ] [ :dependency ] dependencies_array = dependencies_string . split ( " " ) dependencies_array ||= [ ] if dependencies_array . is_a? ( Array ) dependencies_array . any? do | dependency | begin check_name , entity = dependency . split ( "/" ) . reverse if entity =~ / ^subscription:.*$ / subscription_name = entity . split ( ":" ) [ 1 ] subscription_event_exists? ( subscription_name , check_name ) else client_name = entity client_name ||= event [ :client ] [ :name ] client_event_exists? ( client_name , check_name ) end rescue => error @logger . error ( "failed to query api for a check dependency event" , :error => error ) false end end else false end end
Determine if an event exists for any of the check
dependencies declared in the event data, specified in array,
check `dependencies`.
Determine if an event exists for any of the check dependencies declared in the event data specified in array check ` dependencies ` .
None
Boolean
event
<not_specific>
<not_specific>
None