Sha256: 91da22150999810388ded33134e81f82d9ed9b5a75a7f4dfa8e49f07871b30de
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: false # # Checks number of items in a Redis list key # === # # Depends on redis gem # gem install redis # # Copyright (c) 2013, Piavlo <lolitushka@gmail.com> # # 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 RedisListLengthCheck < Sensu::Plugin::Check::CLI include RedisClientOptions option :warn, short: '-w COUNT', long: '--warning COUNT', description: 'COUNT warning threshold for number of items in Redis list key', proc: proc(&:to_i), required: true option :crit, short: '-c COUNT', long: '--critical COUNT', description: 'COUNT critical threshold for number of items in Redis list key', proc: proc(&:to_i), required: true option :key, short: '-k KEY', long: '--key KEY', description: 'Redis list KEY to check', required: true def run redis = Redis.new(default_redis_options) length = case redis.type(config[:key]) when 'hash' redis.hlen(config[:key]) when 'set' redis.scard(config[:key]) else redis.llen(config[:key]) end if length >= config[:crit] critical "Redis list #{config[:key]} length is above the CRITICAL limit: #{length} length / #{config[:crit]} limit" elsif length >= config[:warn] warning "Redis list #{config[:key]} length is above the WARNING limit: #{length} length / #{config[:warn]} limit" else ok "Redis list #{config[:key]} length (#{length}) is below thresholds" 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-list-length.rb |
sensu-plugins-redis-4.1.0 | bin/check-redis-list-length.rb |
sensu-plugins-redis-4.0.0 | bin/check-redis-list-length.rb |