Sha256: 2d6c72dfeb78ac291f0d588726eeecfef3f89e0c0b5998051498db4e3528bb9b

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

#! /usr/bin/env ruby
# frozen_string_literal: false

#   <script name>
#
# DESCRIPTION:
#   Runs Redis ping command to see if Redis is alive
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#   gem: redis
#
# USAGE:
#   check-redis-ping.rb -h redis.example.com -p 6380 -P secret
#
# NOTE:
#   Heavily inspired by check-redis-info.rb
#   https://github.com/sensu/sensu-community-plugins/blob/master/plugins/redis/check-redis-info.rb
#
# LICENSE:
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'
require 'redis'
require_relative '../lib/redis_client_options'

class RedisPing < Sensu::Plugin::Check::CLI
  include RedisClientOptions

  def run
    if Redis.new(default_redis_options).ping == 'PONG'
      ok 'Redis is alive'
    else
      critical 'Redis did not respond to the ping command'
    end
  rescue StandardError
    send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sensu-plugins-redis-5.0.0 bin/check-redis-ping.rb
sensu-plugins-redis-4.1.0 bin/check-redis-ping.rb
sensu-plugins-redis-4.0.0 bin/check-redis-ping.rb