lib/sensu/server/process.rb
def retrieve_client(result)
        client_key = result[:check][:source] || result[:client]
        @redis.get("client:#{client_key}") do |client_json|
          unless client_json.nil?
            client = Sensu::JSON.load(client_json)
            if client[:signature]
              if client[:signature] == result[:signature]
                yield(client)
              else
                @logger.warn("invalid check result signature", {
                  :result => result,
                  :client => client
                })
                @logger.warn("not retrieving client from the registry", :result => result)
                yield(nil)
              end
            else
              yield(client)
            end
          else
            @redis.get("client:#{client_key}:signature") do |signature|
              if signature.nil? || signature.empty? || result[:signature] == signature
                client = create_client(client_key)
                client[:type] = "proxy" if result[:check][:source]
                update_client_registry(client) do
                  yield(client)
                end
              else
                @logger.warn("invalid check result signature", {
                  :result => result,
                  :signature => signature
                })
                yield(nil)
              end
            end
          end
        end
      end
# Retrieve a client (data) from Redis if it exists. If a client
# does not already exist, create one (a blank) using the
# `client_key` as the client name. Dynamically create client
# data can be updated using the API (POST /clients/:client). If
# a client does exist and it has a client signature, the check
# result must have a matching signature or it is discarded. If
# the client does not exist, but a client signature exists, the
# check result must have a matching signature or it is
# discarded.
#
# @param result [Hash] data.
# @yield [client] callback/block to be called with client data,
#   either retrieved from Redis, or dynamically created.
# @yieldparam client [Hash]
Retrieve a client (data) from Redis if it exists. If a client
does not already exist, create one (a blank) using the
`client_key` as the client name. Dynamically create client
data can be updated using the API (POST /clients/:client). If
a client does exist and it has a client signature, the check
result must have a matching signature or it is discarded. If
the client does not exist, but a client signature exists, the
check result must have a matching signature or it is
discarded.
Retrieve a client ( data ) from Redis if it exists . If a client does not already exist create one ( a blank ) using the ` client_key ` as the client name . Dynamically create client data can be updated using the API ( POST / clients / : client ) . If a client does exist and it has a client signature the check result must have a matching signature or it is discarded . If the client does not exist but a client signature exists the check result must have a matching signature or it is discarded .
def retrieve_client(result)
        client_key = result[:check][:source] || result[:client]
        @redis.get("client:#{client_key}") do |client_json|
          unless client_json.nil?
            client = Sensu::JSON.load(client_json)
            if client[:signature]
              if client[:signature] == result[:signature]
                yield(client)
              else
                @logger.warn("invalid check result signature", {
                  :result => result,
                  :client => client
                })
                @logger.warn("not retrieving client from the registry", :result => result)
                yield(nil)
              end
            else
              yield(client)
            end
          else
            @redis.get("client:#{client_key}:signature") do |signature|
              if signature.nil? || signature.empty? || result[:signature] == signature
                client = create_client(client_key)
                client[:type] = "proxy" if result[:check][:source]
                update_client_registry(client) do
                  yield(client)
                end
              else
                @logger.warn("invalid check result signature", {
                  :result => result,
                  :signature => signature
                })
                yield(nil)
              end
            end
          end
        end
      end
def retrieve_client ( result ) client_key = result [ :check ] [ :source ] || result [ :client ] @redis . get ( "client:#{client_key}" ) do | client_json | unless client_json . nil? client = Sensu :: JSON . load ( client_json ) if client [ :signature ] if client [ :signature ] == result [ :signature ] yield ( client ) else @logger . warn ( "invalid check result signature" , { :result => result , :client => client } ) @logger . warn ( "not retrieving client from the registry" , :result => result ) yield ( nil ) end else yield ( client ) end else @redis . get ( "client:#{client_key}:signature" ) do | signature | if signature . nil? || signature . empty? || result [ :signature ] == signature client = create_client ( client_key ) client [ :type ] = "proxy" if result [ :check ] [ :source ] update_client_registry ( client ) do yield ( client ) end else @logger . warn ( "invalid check result signature" , { :result => result , :signature => signature } ) yield ( nil ) end end end end end
Retrieve a client (data) from Redis if it exists.
Retrieve a client ( data ) from Redis if it exists .
result
None
]
callback/block to be called with client data, either retrieved from Redis, or dynamically created.
callback / block to be called with client data either retrieved from Redis or dynamically created .
None