Sha256: b8cfcdd0b164605c3463c85cad5c6d1ed284c7533c277b4c128625e2d7e8cb7e
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: false # # Checks checks variables from redis INFO http://redis.io/commands/INFO # # === # # Depends on redis gem # gem install redis # # === # # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # # Heavily inspired in check-redis-slave-status.rb # https://github.com/sensu/sensu-community-plugins/blob/master/plugins/redis/check-redis-slave-status.rb # require 'sensu-plugin/check/cli' require 'redis' require_relative '../lib/redis_client_options' class RedisSlaveCheck < Sensu::Plugin::Check::CLI include RedisClientOptions option :redis_info_key, short: '-K VALUE', long: '--redis-info-key KEY', description: 'Redis info key to monitor', required: false, default: 'role' option :redis_info_value, short: '-V VALUE', long: '--redis-info-key-value VALUE', description: 'Redis info key value to trigger alarm', required: false, default: 'master' def run redis = Redis.new(default_redis_options) if redis.info.fetch(config[:redis_info_key].to_s) == config[:redis_info_value].to_s ok "Redis #{config[:redis_info_key]} is #{config[:redis_info_value]}" else critical "Redis #{config[:redis_info_key]} is #{redis.info.fetch(config[:redis_info_key].to_s)}!" 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-info.rb |
sensu-plugins-redis-4.1.0 | bin/check-redis-info.rb |
sensu-plugins-redis-4.0.0 | bin/check-redis-info.rb |