lib/sensu/server/process.rb
# Store check result data. This method stores check result data
# and the 21 most recent check result statuses for a client/check
# pair, this history is used for event context and flap detection.
# The check execution timestamp is also stored, to provide an
# indication of how recent the data is. Check output is
# truncated by `truncate_check_output()` before it is stored.
#
# @param client [Hash]
# @param check [Hash]
# @yield [] callback/block called after the check data has been
#   stored (history, etc).
Store check result data. This method stores check result data
and the 21 most recent check result statuses for a client/check
pair, this history is used for event context and flap detection.
The check execution timestamp is also stored, to provide an
indication of how recent the data is. Check output is
truncated by `truncate_check_output()` before it is stored.
Store check result data . This method stores check result data and the 21 most recent check result statuses for a client / check pair this history is used for event context and flap detection . The check execution timestamp is also stored to provide an indication of how recent the data is . Check output is truncated by ` truncate_check_output () ` before it is stored .
def store_check_result(client, check)
        @logger.debug("storing check result", :check => check)
        result_key = "#{client[:name]}:#{check[:name]}"
        history_key = "history:#{result_key}"
        check_truncated = truncate_check_output(check)
        @redis.multi
        @redis.sadd("result:#{client[:name]}", check[:name])
        @redis.set("result:#{result_key}", Sensu::JSON.dump(check_truncated))
        @redis.sadd("ttl", result_key) if check[:ttl]
        @redis.rpush(history_key, check[:status])
        @redis.ltrim(history_key, -21, -1)
        if check[:status] == 0
          @redis.set("#{history_key}:last_ok", check.fetch(:executed, Time.now.to_i))
        end
        @redis.exec do
          yield
        end
      end
def store_check_result ( client , check ) @logger . debug ( "storing check result" , :check => check ) result_key = "#{client[:name]}:#{check[:name]}" history_key = "history:#{result_key}" check_truncated = truncate_check_output ( check ) @redis . multi @redis . sadd ( "result:#{client[:name]}" , check [ :name ] ) @redis . set ( "result:#{result_key}" , Sensu :: JSON . dump ( check_truncated ) ) @redis . sadd ( "ttl" , result_key ) if check [ :ttl ] @redis . rpush ( history_key , check [ :status ] ) @redis . ltrim ( history_key , - 21 , - 1 ) if check [ :status ] == 0 @redis . set ( "#{history_key}:last_ok" , check . fetch ( :executed , Time . now . to_i ) ) end @redis . exec do yield end end
Store check result data.
Store check result data .
client
check
None
]
callback/block called after the check data has been stored (history, etc).
callback / block called after the check data has been stored ( history etc ) .