lib/sensu/server/process.rb
# Determine if an event has been silenced. This method compiles
# an array of possible silenced registry entry keys for the
# event. An attempt is made to fetch one or more of the silenced
# registry entries to determine if the event has been silenced.
# The event data is updated to indicate if the event has been
# silenced. If the event is silenced and the event action is
# `:resolve`, silenced registry entries with
# `:expire_on_resolve` set to true will be deleted. Silencing is
# disabled for events with a check status of `0` (OK), unless
# the event action is `:resolve` or `:flapping`.
#
# @param event [Hash]
# @yield callback [event] callback/block called after the event
#   data has been updated to indicate if it has been silenced.
Determine if an event has been silenced. This method compiles
an array of possible silenced registry entry keys for the
event. An attempt is made to fetch one or more of the silenced
registry entries to determine if the event has been silenced.
The event data is updated to indicate if the event has been
silenced. If the event is silenced and the event action is
`:resolve`, silenced registry entries with
`:expire_on_resolve` set to true will be deleted.
Determine if an event has been silenced . This method compiles an array of possible silenced registry entry keys for the event . An attempt is made to fetch one or more of the silenced registry entries to determine if the event has been silenced . The event data is updated to indicate if the event has been silenced . If the event is silenced and the event action is ` : resolve ` silenced registry entries with ` : expire_on_resolve ` set to true will be deleted .
def event_silenced?(event)
        event[:silenced] = false
        event[:silenced_by] = []
        if event[:check][:status] != 0 || event[:action] != :create
          check_name = event[:check][:name]
          silenced_keys = event[:client][:subscriptions].map { |subscription|
            ["silence:#{subscription}:*", "silence:#{subscription}:#{check_name}"]
          }.flatten
          silenced_keys << "silence:*:#{check_name}"
          @redis.mget(*silenced_keys) do |silenced|
            silenced.compact!
            silenced.each do |silenced_json|
              silenced_info = Sensu::JSON.load(silenced_json)
              if silenced_info[:expire_on_resolve] && event[:action] == :resolve
                silenced_key = "silence:#{silenced_info[:id]}"
                @redis.srem("silenced", silenced_key)
                @redis.del(silenced_key)
              elsif silenced_info[:begin].nil? || silenced_info[:begin] <= Time.now.to_i
                event[:silenced_by] << silenced_info[:id]
              end
            end
            event[:silenced] = !event[:silenced_by].empty?
            yield(event)
          end
        else
          yield(event)
        end
      end
def event_silenced? ( event ) event [ :silenced ] = false event [ :silenced_by ] = [ ] if event [ :check ] [ :status ] != 0 || event [ :action ] != :create check_name = event [ :check ] [ :name ] silenced_keys = event [ :client ] [ :subscriptions ] . map { | subscription | [ "silence:#{subscription}:*" , "silence:#{subscription}:#{check_name}" ] } . flatten silenced_keys << "silence:*:#{check_name}" @redis . mget ( * silenced_keys ) do | silenced | silenced . compact! silenced . each do | silenced_json | silenced_info = Sensu :: JSON . load ( silenced_json ) if silenced_info [ :expire_on_resolve ] && event [ :action ] == :resolve silenced_key = "silence:#{silenced_info[:id]}" @redis . srem ( "silenced" , silenced_key ) @redis . del ( silenced_key ) elsif silenced_info [ :begin ] . nil? || silenced_info [ :begin ] <= Time . now . to_i event [ :silenced_by ] << silenced_info [ :id ] end end event [ :silenced ] = ! event [ :silenced_by ] . empty? yield ( event ) end else yield ( event ) end end
Determine if an event has been silenced.
Determine if an event has been silenced .
event
None
]
callback  callback/block called after the event data has been updated to indicate if it has been silenced.
callback callback / block called after the event data has been updated to indicate if it has been silenced .