class OkComputer::RedisCheck
This class performs a health check on a Redis instance using the INFO command.
It reports the Redis instance’s memory usage, uptime, and number of connected clients.
Constants
- ConnectionFailed
Attributes
Public Class Methods
Source
# File lib/ok_computer/built_in_checks/redis_check.rb, line 15 def initialize(redis_config) @redis_config = redis_config end
Public: Initialize a new Redis check.
redis_config
- The configuration of the Redis instance.
Expects any valid configuration that can be passed to Redis.new. See https://github.com/redis/redis-rb#getting-started
Public Instance Methods
Source
# File lib/ok_computer/built_in_checks/redis_check.rb, line 20 def check info = redis_info mark_message "Connected to redis, #{info['used_memory_human']} used memory, uptime #{info['uptime_in_seconds']} secs, #{info['connected_clients']} connected client(s)" rescue => e mark_failure mark_message "Error: '#{e}'" end
Public: Return the status of Redis.
Source
# File lib/ok_computer/built_in_checks/redis_check.rb, line 37 def redis @redis ||= ::Redis.new(redis_config) end
Returns a redis instance based on configuration
Source
# File lib/ok_computer/built_in_checks/redis_check.rb, line 30 def redis_info redis.info rescue => e raise ConnectionFailed, e end
Returns a hash from Redis’s INFO command.