fluent-plugin-jabber 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/Gemfile +1 -0
- data/README.md +54 -0
- data/fluent-plugin-jabber.gemspec +20 -0
- data/lib/fluent/plugin/jabber.rb +54 -0
- metadata +130 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# fluent-plugin-jabber
|
2
|
+
|
3
|
+
Fluentd output plugin for XMPP(jabber) protocol.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fluent-plugin-jabber'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fluent-plugin-jabber
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
See source for details.
|
22
|
+
|
23
|
+
### Fluentd config
|
24
|
+
|
25
|
+
<match ...>
|
26
|
+
type jabber
|
27
|
+
|
28
|
+
# Pit( https://github.com/cho45/pit ) ID for user account information.
|
29
|
+
# Need 'jid' and 'password' field.
|
30
|
+
pit_id jabber
|
31
|
+
|
32
|
+
# Output target JID. Currently multi user chat only.
|
33
|
+
room test@conference.localhost/test
|
34
|
+
</match>
|
35
|
+
|
36
|
+
### Message format
|
37
|
+
|
38
|
+
{"body": "String for output"}
|
39
|
+
|
40
|
+
If 'body' field not set, the plugin raises error.
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
49
|
+
|
50
|
+
## Changes
|
51
|
+
|
52
|
+
### 0.0.1
|
53
|
+
|
54
|
+
Initial release.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = "fluent-plugin-jabber"
|
3
|
+
gem.version = "0.0.1"
|
4
|
+
gem.authors = ["todesking"]
|
5
|
+
gem.email = ["discommunicative@gmail.com"]
|
6
|
+
gem.summary = %q{Fluentd output plugin for XMPP(Jabber) protocol}
|
7
|
+
gem.homepage = "https://github.com/todesking/fluent-plugin-jabber"
|
8
|
+
|
9
|
+
gem.files = `git ls-files`.split($\)
|
10
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
11
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
12
|
+
gem.require_paths = ["lib"]
|
13
|
+
|
14
|
+
gem.add_development_dependency "rake"
|
15
|
+
gem.add_development_dependency "fluentd"
|
16
|
+
|
17
|
+
gem.add_runtime_dependency "xmpp4r"
|
18
|
+
gem.add_runtime_dependency "fluentd"
|
19
|
+
gem.add_runtime_dependency "pit"
|
20
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'fluent/plugin'
|
2
|
+
require 'fluent/config'
|
3
|
+
require 'fluent/output'
|
4
|
+
|
5
|
+
require 'xmpp4r'
|
6
|
+
require 'xmpp4r/muc'
|
7
|
+
|
8
|
+
require 'pit'
|
9
|
+
|
10
|
+
class Fluent::JabberOutput < Fluent::Output
|
11
|
+
Fluent::Plugin.register_output('jabber', self)
|
12
|
+
|
13
|
+
config_param :pit_id, :string
|
14
|
+
|
15
|
+
# Currently, output target is group chat only.
|
16
|
+
config_param :room, :string
|
17
|
+
|
18
|
+
def configure(conf)
|
19
|
+
super
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
user_info = Pit.get(@pit_id, require: {
|
24
|
+
'jid' => 'jid',
|
25
|
+
'password' => 'password',
|
26
|
+
})
|
27
|
+
|
28
|
+
jid = Jabber::JID.new(user_info['jid'])
|
29
|
+
@client = Jabber::Client.new(jid)
|
30
|
+
@client.connect
|
31
|
+
@client.auth(user_info['password'])
|
32
|
+
|
33
|
+
@muc_client = Jabber::MUC::MUCClient.new(@client)
|
34
|
+
@muc_client.join(@room)
|
35
|
+
|
36
|
+
$log.info("out_jabber plugin initialized(jid: #{user_info['jid']}, room: #{@room})")
|
37
|
+
end
|
38
|
+
|
39
|
+
def shutdown
|
40
|
+
@client.close
|
41
|
+
end
|
42
|
+
|
43
|
+
def emit(tag, es, chain)
|
44
|
+
es.each do|time, record|
|
45
|
+
@muc_client.send create_message(time, record)
|
46
|
+
end
|
47
|
+
chain.next
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_message(time, record)
|
51
|
+
raise "record['body'] is empty" unless record['body']
|
52
|
+
Jabber::Message.new(@room, record['body'])
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-jabber
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- todesking
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: fluentd
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: xmpp4r
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: fluentd
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: pit
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description:
|
95
|
+
email:
|
96
|
+
- discommunicative@gmail.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Gemfile
|
103
|
+
- README.md
|
104
|
+
- fluent-plugin-jabber.gemspec
|
105
|
+
- lib/fluent/plugin/jabber.rb
|
106
|
+
homepage: https://github.com/todesking/fluent-plugin-jabber
|
107
|
+
licenses: []
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 1.8.24
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: Fluentd output plugin for XMPP(Jabber) protocol
|
130
|
+
test_files: []
|