lib/sensu/server/process.rb
def create_client_keepalive_check_results(clients)
        client_keys = clients.map { |client_name| "client:#{client_name}" }
        @redis.mget(*client_keys) do |client_json_objects|
          client_json_objects.each do |client_json|
            unless client_json.nil?
              client = Sensu::JSON.load(client_json)
              next if client[:keepalives] == false
              check, unmatched_tokens = create_keepalive_check(client)
              time_since_last_keepalive = Time.now.to_i - client[:timestamp]
              check[:output] = "No keepalive sent from client for "
              check[:output] << "#{time_since_last_keepalive} seconds"
              case
              when time_since_last_keepalive >= check[:thresholds][:critical]
                check[:output] << " (>=#{check[:thresholds][:critical]})"
                check[:status] = 2
              when time_since_last_keepalive >= check[:thresholds][:warning]
                check[:output] << " (>=#{check[:thresholds][:warning]})"
                check[:status] = 1
              else
                check[:output] = "Keepalive sent from client "
                check[:output] << "#{time_since_last_keepalive} seconds ago"
                check[:status] = 0
              end
              unless unmatched_tokens.empty?
                check[:output] << " - Unmatched client token(s): " + unmatched_tokens.join(", ")
                check[:status] = 1 if check[:status] == 0
              end
              publish_check_result(client[:name], check)
            end
          end
          yield
        end
      end
# Create client keepalive check results. This method will
# retrieve clients from the registry, creating a keepalive
# check definition for each client, using the
# `create_keepalive_check()` method, containing client specific
# keepalive thresholds. If the time since the latest keepalive
# is equal to or greater than a threshold, the check `:output`
# is set to a descriptive message, and `:status` is set to the
# appropriate non-zero value. If a client has been sending
# keepalives, `:output` and `:status` are set to indicate an OK
# state. The `publish_check_result()` method is used to publish
# the client keepalive check results.
#
# @param clients [Array] of client names.
# @yield [] callback/block called after the client keepalive
#   check results have been created.
Create client keepalive check results. This method will
retrieve clients from the registry, creating a keepalive
check definition for each client, using the
`create_keepalive_check()` method, containing client specific
keepalive thresholds. If the time since the latest keepalive
is equal to or greater than a threshold, the check `:output`
is set to a descriptive message, and `:status` is set to the
appropriate non-zero value. If a client has been sending
keepalives, `:output` and `:status` are set to indicate an OK
state. The `publish_check_result()` method is used to publish
the client keepalive check results.
Create client keepalive check results . This method will retrieve clients from the registry creating a keepalive check definition for each client using the ` create_keepalive_check () ` method containing client specific keepalive thresholds . If the time since the latest keepalive is equal to or greater than a threshold the check ` : output ` is set to a descriptive message and ` : status ` is set to the appropriate non - zero value . If a client has been sending keepalives ` : output ` and ` : status ` are set to indicate an OK state . The ` publish_check_result () ` method is used to publish the client keepalive check results .
def create_client_keepalive_check_results(clients)
        client_keys = clients.map { |client_name| "client:#{client_name}" }
        @redis.mget(*client_keys) do |client_json_objects|
          client_json_objects.each do |client_json|
            unless client_json.nil?
              client = Sensu::JSON.load(client_json)
              next if client[:keepalives] == false
              check, unmatched_tokens = create_keepalive_check(client)
              time_since_last_keepalive = Time.now.to_i - client[:timestamp]
              check[:output] = "No keepalive sent from client for "
              check[:output] << "#{time_since_last_keepalive} seconds"
              case
              when time_since_last_keepalive >= check[:thresholds][:critical]
                check[:output] << " (>=#{check[:thresholds][:critical]})"
                check[:status] = 2
              when time_since_last_keepalive >= check[:thresholds][:warning]
                check[:output] << " (>=#{check[:thresholds][:warning]})"
                check[:status] = 1
              else
                check[:output] = "Keepalive sent from client "
                check[:output] << "#{time_since_last_keepalive} seconds ago"
                check[:status] = 0
              end
              unless unmatched_tokens.empty?
                check[:output] << " - Unmatched client token(s): " + unmatched_tokens.join(", ")
                check[:status] = 1 if check[:status] == 0
              end
              publish_check_result(client[:name], check)
            end
          end
          yield
        end
      end
def create_client_keepalive_check_results ( clients ) client_keys = clients . map { | client_name | "client:#{client_name}" } @redis . mget ( * client_keys ) do | client_json_objects | client_json_objects . each do | client_json | unless client_json . nil? client = Sensu :: JSON . load ( client_json ) next if client [ :keepalives ] == false check , unmatched_tokens = create_keepalive_check ( client ) time_since_last_keepalive = Time . now . to_i - client [ :timestamp ] check [ :output ] = "No keepalive sent from client for " check [ :output ] << "#{time_since_last_keepalive} seconds" case when time_since_last_keepalive >= check [ :thresholds ] [ :critical ] check [ :output ] << " (>=#{check[:thresholds][:critical]})" check [ :status ] = 2 when time_since_last_keepalive >= check [ :thresholds ] [ :warning ] check [ :output ] << " (>=#{check[:thresholds][:warning]})" check [ :status ] = 1 else check [ :output ] = "Keepalive sent from client " check [ :output ] << "#{time_since_last_keepalive} seconds ago" check [ :status ] = 0 end unless unmatched_tokens . empty? check [ :output ] << " - Unmatched client token(s): " + unmatched_tokens . join ( ", " ) check [ :status ] = 1 if check [ :status ] == 0 end publish_check_result ( client [ :name ] , check ) end end yield end end
Create client keepalive check results.
Create client keepalive check results .
clients
of client names.
of client names .
]
callback/block called after the client keepalive check results have been created.
callback / block called after the client keepalive check results have been created .