bin/riemann-redis in riemann-tools-0.1.1 vs bin/riemann-redis in riemann-tools-0.1.2
- old
+ new
@@ -9,24 +9,50 @@
require 'redis'
opt :redis_host, "Redis hostname", :default => 'localhost'
opt :redis_port, "Redis port", :default => 6379
opt :redis_password, "Redis password", :default => ''
+ opt :redis_url, "Redis URL", :default => ''
+ opt :redis_socket, "Redis socket", :default => ''
+ opt :redis_section, "Redis INFO section", :default => 'default'
+ STRING_VALUES = %w{ redis_version redis_git_sha1 redis_mode os
+ multiplexing_api gcc_version run_id used_memory_human
+ used_memory_peak_human mem_allocator
+ rdb_last_bgsave_status aof_last_bgrewrite_status role }
+
def initialize
- @redis = ::Redis.new(:host => opts[:redis_host], :port => opts[:redis_port])
+ options = if opts[:redis_url] != ''
+ { :url => opts[:redis_url] }
+ elsif opts[:redis_socket] != ''
+ { :path => opts[:redis_socket] }
+ else
+ { :host => opts[:redis_host], :port => opts[:redis_port] }
+ end
+ @redis = ::Redis.new(options)
@redis.auth(opts[:redis_password]) unless opts[:redis_password] == ''
+ @section = opts[:redis_section]
end
def tick
- @redis.info.each do |property, value|
- report(
+ @redis.info(@section).each do |property, value|
+ data = {
:host => opts[:redis_host],
:service => "redis #{property}",
:metric => value.to_f,
:state => 'ok',
:tags => ['redis']
- )
+ }
+
+ if STRING_VALUES.include?(property) || property.match(/^db\d+/)
+ if %w{ rdb_last_bgsave_status aof_last_bgrewrite_status }.include?(property)
+ data[:state] = value
+ else
+ data[:description] = value
+ end
+ end
+
+ report(data)
end
end
end