bin/metrics-redis-llen.rb in sensu-plugins-redis-2.2.2 vs bin/metrics-redis-llen.rb in sensu-plugins-redis-2.3.0
- old
+ new
@@ -48,32 +48,35 @@
short: '-S SCHEME',
long: '--scheme SCHEME',
default: "#{Socket.gethostname}.redis"
option :key,
- short: '-k KEY',
+ short: '-k KEY1,KEY2',
long: '--key KEY',
- description: 'Redis list KEY to check',
+ description: 'Comma separated list of keys to check',
required: true
option :conn_failure_status,
long: '--conn-failure-status EXIT_STATUS',
description: 'Returns the following exit status for Redis connection failures',
default: 'unknown',
in: %w(unknown warning critical)
def run
+ redis_keys = config[:key].split(',')
options = if config[:socket]
{ path: socket }
else
{ host: config[:host], port: config[:port] }
end
options[:db] = config[:database]
options[:password] = config[:password] if config[:password]
redis = Redis.new(options)
- output "#{config[:scheme]}.#{config[:key]}.items", redis.llen(config[:key])
+ redis_keys.each do |key|
+ output "#{config[:scheme]}.#{key}.items", redis.llen(key)
+ end
ok
rescue
send(config[:conn_failure_status], "Could not connect to Redis server on #{config[:host]}:#{config[:port]}")
end
end