mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
simple xmpp input example
This commit is contained in:
parent
63022f354e
commit
e235d3c671
1 changed files with 29 additions and 0 deletions
29
examples/simple_xmpp_input.rb
Normal file
29
examples/simple_xmpp_input.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'logstash/inputs/base'
|
||||
require 'logstash/namespace'
|
||||
|
||||
class LogStash::Inputs::Xmpp < LogStash::Inputs::Base
|
||||
|
||||
config_name 'xmpp'
|
||||
config :jid, :validate => :string
|
||||
config :password, :validate => :string
|
||||
|
||||
public
|
||||
def register
|
||||
require 'xmpp4r-simple' # xmpp4r-simple gem
|
||||
end
|
||||
|
||||
def run(queue)
|
||||
# Setup the connection
|
||||
@im = Jabber::Simple.new("#{@jid}", "#{@password}")
|
||||
loop do
|
||||
# For all messages received, convert 'em to events
|
||||
@im.received_messages { |msg|
|
||||
e = to_event(msg.body, msg.from)
|
||||
if e
|
||||
queue << e
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue