lib/sensu/server/process.rb
def create_check_ttl_results(ttl_keys, interval=30)
        result_keys = ttl_keys.map { |ttl_key| "result:#{ttl_key}" }
        @redis.mget(*result_keys) do |result_json_objects|
          result_json_objects.each_with_index do |result_json, index|
            unless result_json.nil?
              check = Sensu::JSON.load(result_json)
              next unless check[:ttl] && check[:executed] && !check[:force_resolve]
              time_since_last_execution = Time.now.to_i - check[:executed]
              if time_since_last_execution >= check[:ttl]
                client_name = ttl_keys[index].split(":").first
                keepalive_event_exists?(client_name) do |event_exists|
                  unless event_exists
                    check[:output] = "Last check execution was "
                    check[:output] << "#{time_since_last_execution} seconds ago"
                    check[:status] = check[:ttl_status] || 1
                    check[:interval] = interval
                    publish_check_result(client_name, check)
                  end
                end
              end
            else
              @redis.srem("ttl", ttl_keys[index])
            end
          end
          yield
        end
      end
# Create check TTL results. This method will retrieve check
# results from the registry and determine the time since their
# last check execution (in seconds). If the time since last
# execution is equal to or greater than the defined check TTL, a
# warning check result is published with the appropriate check
# output.
#
# @param ttl_keys [Array] of TTL keys.
# @param interval [Integer] to use for the check TTL result
#   interval.
# @yield [] callback/block called after the check TTL results
#   have been created.
Create check TTL results. This method will retrieve check
results from the registry and determine the time since their
last check execution (in seconds). If the time since last
execution is equal to or greater than the defined check TTL, a
warning check result is published with the appropriate check
output.
Create check TTL results . This method will retrieve check results from the registry and determine the time since their last check execution ( in seconds ) . If the time since last execution is equal to or greater than the defined check TTL a warning check result is published with the appropriate check output .
def create_check_ttl_results(ttl_keys, interval=30)
        result_keys = ttl_keys.map { |ttl_key| "result:#{ttl_key}" }
        @redis.mget(*result_keys) do |result_json_objects|
          result_json_objects.each_with_index do |result_json, index|
            unless result_json.nil?
              check = Sensu::JSON.load(result_json)
              next unless check[:ttl] && check[:executed] && !check[:force_resolve]
              time_since_last_execution = Time.now.to_i - check[:executed]
              if time_since_last_execution >= check[:ttl]
                client_name = ttl_keys[index].split(":").first
                keepalive_event_exists?(client_name) do |event_exists|
                  unless event_exists
                    check[:output] = "Last check execution was "
                    check[:output] << "#{time_since_last_execution} seconds ago"
                    check[:status] = check[:ttl_status] || 1
                    check[:interval] = interval
                    publish_check_result(client_name, check)
                  end
                end
              end
            else
              @redis.srem("ttl", ttl_keys[index])
            end
          end
          yield
        end
      end
def create_check_ttl_results ( ttl_keys , interval = 30 ) result_keys = ttl_keys . map { | ttl_key | "result:#{ttl_key}" } @redis . mget ( * result_keys ) do | result_json_objects | result_json_objects . each_with_index do | result_json , index | unless result_json . nil? check = Sensu :: JSON . load ( result_json ) next unless check [ :ttl ] && check [ :executed ] && ! check [ :force_resolve ] time_since_last_execution = Time . now . to_i - check [ :executed ] if time_since_last_execution >= check [ :ttl ] client_name = ttl_keys [ index ] . split ( ":" ) . first keepalive_event_exists? ( client_name ) do | event_exists | unless event_exists check [ :output ] = "Last check execution was " check [ :output ] << "#{time_since_last_execution} seconds ago" check [ :status ] = check [ :ttl_status ] || 1 check [ :interval ] = interval publish_check_result ( client_name , check ) end end end else @redis . srem ( "ttl" , ttl_keys [ index ] ) end end yield end end
Create check TTL results.
Create check TTL results .
ttl_keys
of TTL keys.
of TTL keys .
interval
to use for the check TTL result interval.
to use for the check TTL result interval .
]
callback/block called after the check TTL results have been created.
callback / block called after the check TTL results have been created .