bin/metrics-redis-llen.rb in sensu-plugins-redis-1.2.2 vs bin/metrics-redis-llen.rb in sensu-plugins-redis-1.3.0
- old
+ new
@@ -9,10 +9,16 @@
require 'sensu-plugin/metric/cli'
require 'redis'
class RedisListLengthMetric < Sensu::Plugin::Metric::CLI::Graphite
+ option :socket,
+ short: '-s SOCKET',
+ long: '--socket SOCKET',
+ description: 'Redis socket to connect to (overrides Host and Port)',
+ required: false
+
option :host,
short: '-h HOST',
long: '--host HOST',
description: 'Redis Host to connect to',
default: '127.0.0.1'
@@ -40,10 +46,15 @@
long: '--key KEY',
description: 'Redis list KEY to check',
required: true
def run
- options = { host: config[:host], port: config[:port] }
+ options = if config[:socket]
+ { path: socket }
+ else
+ { host: config[:host], port: config[:port] }
+ end
+
options[:password] = config[:password] if config[:password]
redis = Redis.new(options)
output "#{config[:scheme]}.#{config[:key]}.items", redis.llen(config[:key])
ok