mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Merge pull request #35 from freemed/master
- Handle non-integer ganglia values, based on type. - add XMPP output.
This commit is contained in:
commit
4387f42159
4 changed files with 50 additions and 1 deletions
1
Gemfile
1
Gemfile
|
@ -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
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
37
lib/logstash/outputs/xmpp.rb
Normal file
37
lib/logstash/outputs/xmpp.rb
Normal 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
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue