Skip to content

Commit

Permalink
changes per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kcrayon committed Nov 9, 2013
1 parent 0e616ef commit f23b2d7
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions extensions/handlers/redis_output.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
module Sensu::Extension
class RedisOutput < Handler
def definition
{
type: 'extension',
name: 'redis_output',
}
end

def name
definition[:name]
'redis_output'
end

def description
'outputs events output to a redis list or channel'
end

def post_init
@redis = Sensu::Redis.connect({
:host => @settings["redis_output"]["host"],
:port => @settings["redis_output"]["port"] || 6379,
:database => @settings["redis_output"]["db"] || 0,
})
end

def run(event)
opts = @settings["redis_output"]

opts["db"] ||= 0
opts["port"] ||= 6379
@redis ||= Sensu::Redis.connect(:host => opts["host"], :port => opts["port"], :db => opts["db"])

output = Oj.load(event)[:check][:output]
output = opts["split"] ? output.split("\n") : Array(output)
output = output.split("\m") if opts["split"]

output.each do |e|
Array(output).each do |e|
case opts["data_type"]
when "list"
@redis.lpush(opts["key"], e)
Expand Down

0 comments on commit f23b2d7

Please sign in to comment.