lib/sensu/server/process.rb
def update_client_registry(client)
        @logger.debug("updating client registry", :client => client)
        client_key = "client:#{client[:name]}"
        client[:subscriptions] = (client[:subscriptions] + [client_key]).uniq
        signature_key = "#{client_key}:signature"
        @redis.setnx(signature_key, client[:signature]) do |created|
          process_client_registration(client) if created
          @redis.get(signature_key) do |signature|
            if (signature.nil? || signature.empty?) && client[:signature]
              @redis.set(signature_key, client[:signature])
            end
            if signature.nil? || signature.empty? || client[:signature] == signature
              @redis.multi
              @redis.set(client_key, Sensu::JSON.dump(client))
              @redis.sadd("clients", client[:name])
              @redis.exec do
                yield(true) if block_given?
              end
            else
              @logger.warn("invalid client signature", {
                :client => client,
                :signature => signature
              })
              @logger.warn("not updating client in the registry", :client => client)
              yield(false) if block_given?
            end
          end
        end
      end
# Update the Sensu client registry, stored in Redis. Sensu
# client data is used to provide additional event context and
# enable agent health monitoring.
#
# To enable silencing individual clients, per-client
# subscriptions (`client:$CLIENT_NAME`) are added to client
# subscriptions automatically.
#
# The client registry supports client signatures, unique string
# identifiers used for keepalive and result source
# verification. If a client has a signature, all further
# registry updates for the client must have the same
# signature. A client can begin to use a signature if one was
# not previously configured. JSON serialization is used for the
# stored client data.
#
# @param client [Hash]
# @yield [success] passes success status to optional
#   callback/block.
# @yieldparam success [TrueClass,FalseClass] indicating if the
#   client registry update was a success or the client data was
#   discarded due to client signature mismatch.
Update the Sensu client registry, stored in Redis. Sensu
client data is used to provide additional event context and
enable agent health monitoring.

To enable silencing individual clients, per-client
subscriptions (`client:$CLIENT_NAME`) are added to client
subscriptions automatically.

The client registry supports client signatures, unique string
identifiers used for keepalive and result source
verification. If a client has a signature, all further
registry updates for the client must have the same
signature. A client can begin to use a signature if one was
not previously configured. JSON serialization is used for the
stored client data.
Update the Sensu client registry stored in Redis . Sensu client data is used to provide additional event context and enable agent health monitoring . To enable silencing individual clients per - client subscriptions ( ` client : $CLIENT_NAME ` ) are added to client subscriptions automatically . The client registry supports client signatures unique string identifiers used for keepalive and result source verification . If a client has a signature all further registry updates for the client must have the same signature . A client can begin to use a signature if one was not previously configured . JSON serialization is used for the stored client data .
def update_client_registry(client)
        @logger.debug("updating client registry", :client => client)
        client_key = "client:#{client[:name]}"
        client[:subscriptions] = (client[:subscriptions] + [client_key]).uniq
        signature_key = "#{client_key}:signature"
        @redis.setnx(signature_key, client[:signature]) do |created|
          process_client_registration(client) if created
          @redis.get(signature_key) do |signature|
            if (signature.nil? || signature.empty?) && client[:signature]
              @redis.set(signature_key, client[:signature])
            end
            if signature.nil? || signature.empty? || client[:signature] == signature
              @redis.multi
              @redis.set(client_key, Sensu::JSON.dump(client))
              @redis.sadd("clients", client[:name])
              @redis.exec do
                yield(true) if block_given?
              end
            else
              @logger.warn("invalid client signature", {
                :client => client,
                :signature => signature
              })
              @logger.warn("not updating client in the registry", :client => client)
              yield(false) if block_given?
            end
          end
        end
      end
def update_client_registry ( client ) @logger . debug ( "updating client registry" , :client => client ) client_key = "client:#{client[:name]}" client [ :subscriptions ] = ( client [ :subscriptions ] + [ client_key ] ) . uniq signature_key = "#{client_key}:signature" @redis . setnx ( signature_key , client [ :signature ] ) do | created | process_client_registration ( client ) if created @redis . get ( signature_key ) do | signature | if ( signature . nil? || signature . empty? ) && client [ :signature ] @redis . set ( signature_key , client [ :signature ] ) end if signature . nil? || signature . empty? || client [ :signature ] == signature @redis . multi @redis . set ( client_key , Sensu :: JSON . dump ( client ) ) @redis . sadd ( "clients" , client [ :name ] ) @redis . exec do yield ( true ) if block_given? end else @logger . warn ( "invalid client signature" , { :client => client , :signature => signature } ) @logger . warn ( "not updating client in the registry" , :client => client ) yield ( false ) if block_given? end end end end
Update the Sensu client registry, stored in Redis.
Update the Sensu client registry stored in Redis .
client
None
]
passes success status to optional callback/block.
passes success status to optional callback / block .
success
indicating if the client registry update was a success or the client data was discarded due to client signature mismatch.
indicating if the client registry update was a success or the client data was discarded due to client signature mismatch .