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
redis_config[R]
Public Class Methods
new(redis_config)
click to toggle source
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
# File lib/ok_computer/built_in_checks/redis_check.rb, line 15 def initialize(redis_config) @redis_config = redis_config end
Public Instance Methods
check()
click to toggle source
Public: Return the status of Redis.
# 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
redis()
click to toggle source
Returns a redis instance based on configuration
# File lib/ok_computer/built_in_checks/redis_check.rb, line 37 def redis @redis ||= ::Redis.new(redis_config) end
redis_info()
click to toggle source
Returns a hash from Redis’s INFO command.
# File lib/ok_computer/built_in_checks/redis_check.rb, line 30 def redis_info redis.info rescue => e raise ConnectionFailed, e end