Sha256: 19550aa41f2aef7907646f5c90d539311c04640a3ff7fd98ee21dd91654d2c1d

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env ruby
#
# Checks Redis Slave Replication

require 'sensu-plugin/check/cli'
require 'redis'

class RedisSlaveCheck < Sensu::Plugin::Check::CLI
  option :host,
         short: '-h HOST',
         long: '--host HOST',
         description: 'Redis Host to connect to',
         required: false,
         default: '127.0.0.1'

  option :port,
         short: '-p PORT',
         long: '--port PORT',
         description: 'Redis Port to connect to',
         proc: proc(&:to_i),
         required: false,
         default: 6379

  option :password,
         short: '-P PASSWORD',
         long: '--password PASSWORD',
         description: 'Redis Password to connect with'

  def run
    options = { host: config[:host], port: config[:port] }
    options[:password] = config[:password] if config[:password]
    redis = Redis.new(options)

    if redis.info.fetch('master_link_status') == 'up'
      ok 'The redis master links status is up!'
    else
      msg = ''
      msg += "The redis master link status to: #{redis.info.fetch('master_host')} is down!"
      msg += " It has been down for #{redis.info.fetch('master_link_down_since_seconds')}."
      critical msg
    end

  rescue KeyError
    critical "Redis server on #{config[:host]}:#{config[:port]} is master"

  rescue
    critical "Could not connect to Redis server on #{config[:host]}:#{config[:port]}"
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sensu-plugins-redis-1.0.0 bin/check-redis-slave-status.rb
sensu-plugins-redis-0.1.0 bin/check-redis-slave-status.rb
sensu-plugins-redis-0.0.4 bin/check-redis-slave-status.rb
sensu-plugins-redis-0.0.3 bin/check-redis-slave-status.rb
sensu-plugins-redis-0.0.2 bin/check-redis-slave-status.rb
sensu-plugins-redis-0.0.1 bin/check-redis-slave-status.rb