Sha256: e11dda0c2ca07df8c755622c4f2138c4ea54083f6e964f32de4181f54366a150
Contents?: true
Size: 1.24 KB
Versions: 11
Compression:
Stored size: 1.24 KB
Contents
#!/usr/bin/env ruby # Gathers Redis SLOWLOG statistics and submits them to Riemann. require File.expand_path('../../lib/riemann/tools', __FILE__) class Riemann::Tools::RedisSlowlog include Riemann::Tools require 'redis' opt :redis_url, "Redis URL", :default => 'redis://127.0.0.1:6379/' opt :redis_password, "Redis password", :default => '' opt :slowlog_len, "Number of SLOWLOG entries to get", :default => 10 opt :slowlog_reset, "Reset SLOWLOG after querying it", :default => false def initialize @redis = ::Redis.new(url: opts[:redis_url]) @slowlog_len = opts[:slowlog_len] @slowlog_reset = opts[:slowlog_reset] @redis.auth(opts[:redis_password]) unless opts[:redis_password] == '' end def tick @redis.slowlog("GET", @slowlog_len).each do |id, timestamp, us, cmd| data = { :host => @redis.client.host, :service => "redis", :time => timestamp, :metric => us.to_f, :state => 'warning', :tags => ['redis', 'slowlog'], :description => cmd.inspect } report(data) end @redis.slowlog("RESET") if @slowlog_reset end end Riemann::Tools::RedisSlowlog.run
Version data entries
11 entries across 11 versions & 2 rubygems