Class: LogStash::Outputs::Xmpp

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/xmpp.rb

Overview

This output allows you ship events over XMPP/Jabber.

This plugin can be used for posting events to humans over XMPP, or you can use it for PubSub or general message passing for logstash to logstash.

Instance Method Summary collapse

Instance Method Details

#connectObject



52
53
54
55
56
57
58
# File 'lib/logstash/outputs/xmpp.rb', line 52

def connect
  Jabber::debug = true
  client = Jabber::Client.new(Jabber::JID.new(@user))
  client.connect(@host)
  client.auth(@password.value)
  return client
end

#receive(event) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/logstash/outputs/xmpp.rb', line 61

def receive(event)
  

  string_message = event.sprintf(@message)
  @users.each do |user|
    msg = Jabber::Message.new(user, string_message)
    msg.type = :chat
    @client.send(msg)
  end # @targets.each

  msg = Jabber::Message.new(nil, string_message)
  msg.type = :groupchat
  @mucs.each do |muc|
    muc.send(msg)
  end # @mucs.each
end

#registerObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/logstash/outputs/xmpp.rb', line 33

def register
  require "xmpp4r"
  @client = connect

  @mucs = []
  @users = [] if !@users

  # load the MUC Client if we are joining rooms.
  if @rooms && !@rooms.empty?
    require 'xmpp4r/muc'
    @rooms.each do |room| # handle muc messages in different rooms
      muc = Jabber::MUC::MUCClient.new(@client)
      muc.join(room)
      @mucs << muc
    end # @rooms.each
  end # if @rooms
end