Merge remote-tracking branch 'logstashmaster/master'

This commit is contained in:
Nick Ethier 2011-08-11 12:57:17 -06:00
commit e5a70d00fb
4 changed files with 50 additions and 1 deletions

View file

@ -21,6 +21,7 @@ gem "redis" # outputs/redis, License: MIT-style
gem "gelf" # outputs/gelf, # License: MIT-style
gem "statsd-ruby", "~> 0.3.0" # outputs/statsd, # License: As-Is
gem "gmetric", "~> 0.1.3" # outputs/ganglia, # License: MIT
gem "xmpp4r", "~> 0.1.3" # outputs/xmpp, # License: As-Is
# For testing/dev
group :development do

View file

@ -41,11 +41,21 @@ class LogStash::Outputs::Ganglia < LogStash::Outputs::Base
public
def receive(event)
# gmetric only takes integer values, so convert it to int.
case @type
when "string"
localvalue = event.sprintf(@value)
when "float"
localvalue = event.sprintf(@value).to_f
when "double"
localvalue = event.sprintf(@value).to_f
else # int8|uint8|int16|uint16|int32|uint32
localvalue = event.sprintf(@value).to_i
end
Ganglia::GMetric.send(@host, @port, {
:name => event.sprintf(@metric),
:units => @units,
:type => @type,
:value => event.sprintf(@value).to_i,
:value => localvalue,
:tmax => @tmax,
:dmax => @dmax
})

View file

@ -0,0 +1,37 @@
require "logstash/outputs/base"
require "logstash/namespace"
require "xmpp4r"
# This output allows you to pull metrics from your logs and ship them to
# XMPP/Jabber.
class LogStash::Outputs::Xmpp< LogStash::Outputs::Base
config_name "xmpp"
# Connection information for server
config :resource, :validate => :string, :required => true
config :password, :validate => :string, :required => true
config :targets, :validate => :array, :required => true
# The message to send. This supports dynamic strings like %{@source_host}
config :message, :validate => :string, :required => true
def register
@client = connect
end # def register
def connect
client = Client.new(JID::new(@resource))
client.connect
client.auth(@password)
end # def connect
public
def receive(event)
t = event.sprintf(@message)
@targets.each do |target|
msg = Message::new("#{target}", t)
msg.type=:chat
@client.send(msg)
end
end # def receive
end # class LogStash::Outputs::Xmpp

View file

@ -47,6 +47,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "gelf" # outputs/gelf
spec.add_dependency "statsd-ruby" # outputs/statsd
spec.add_dependency "gmetric" # outputs/ganglia
spec.add_dependency "xmpp4r" # outputs/xmpp
# For the 'grok' filter
spec.add_dependency("jls-grok", "~> 0.4.7")