fluent-plugin-mqtt 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-mqtt.gemspec +1 -1
- data/lib/fluent/plugin/in_mqtt.rb +4 -4
- data/lib/fluent/plugin/out_mqtt.rb +91 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd8e3a50f128c2eed1ad45698e0717d60f1af41
|
4
|
+
data.tar.gz: 17a9e5405a4d7d72e14773c7e29d43cd596a1b9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a182d419e6e18de083194728813d0d7c7fb41a680499947e037a050a5a1c7723e81daa8adb60f286eaf841a36ee72d9b7d58d625fc2becd9c7984cc93a263ccc
|
7
|
+
data.tar.gz: f4424914b01c172b33cfd7b68036ff9b20184ed0c24fabcdddc8a8a516f9839e13e9efe3c94563398539402ac36cf01be547a54d67fb2e7f78142f702ca66cd4
|
data/fluent-plugin-mqtt.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-mqtt"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.5"
|
8
8
|
spec.authors = ["Yuuna Kurita"]
|
9
9
|
spec.email = ["yuuna.m@gmail.com"]
|
10
10
|
spec.summary = %q{fluentd input plugin for mqtt server}
|
@@ -43,12 +43,12 @@ module Fluent
|
|
43
43
|
def start
|
44
44
|
$log.debug "start mqtt #{@bind}"
|
45
45
|
opts = {host: @bind,
|
46
|
-
port: @port
|
47
|
-
|
48
|
-
|
46
|
+
port: @port}
|
47
|
+
opts[:username] = @username if @username
|
48
|
+
opts[:password] = @password if @password
|
49
49
|
opts[:ssl] = @ssl if @ssl
|
50
50
|
opts[:ca_file] = @ca if @ca
|
51
|
-
opts[:
|
51
|
+
opts[:cert_file] = @crt if @crt
|
52
52
|
opts[:key_file] = @key if @key
|
53
53
|
@connect = MQTT::Client.connect(opts)
|
54
54
|
@connect.subscribe(@topic)
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Fluent
|
2
|
+
class OutMqtt < BufferedOutput
|
3
|
+
Plugin.register_output('mqtt', self)
|
4
|
+
|
5
|
+
include Fluent::SetTagKeyMixin
|
6
|
+
config_set_default :include_tag_key, false
|
7
|
+
|
8
|
+
include Fluent::SetTimeKeyMixin
|
9
|
+
config_set_default :include_time_key, true
|
10
|
+
|
11
|
+
|
12
|
+
config_param :port, :integer, :default => 1883
|
13
|
+
config_param :bind, :string, :default => '127.0.0.1'
|
14
|
+
config_param :topic, :string, :default => 'td-agent'
|
15
|
+
config_param :format, :string, :default => 'none'
|
16
|
+
config_param :username, :string, :default => nil
|
17
|
+
config_param :password, :string, :default => nil
|
18
|
+
config_param :ssl, :bool, :default => nil
|
19
|
+
config_param :ca, :string, :default => nil
|
20
|
+
config_param :key, :string, :default => nil
|
21
|
+
config_param :cert, :string, :default => nil
|
22
|
+
|
23
|
+
require 'mqtt'
|
24
|
+
|
25
|
+
unless method_defined?(:log)
|
26
|
+
define_method(:log) { $log }
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
super
|
31
|
+
require 'msgpack'
|
32
|
+
|
33
|
+
@clients = {}
|
34
|
+
@connection_options = {}
|
35
|
+
@collection_options = {:capped => false}
|
36
|
+
end
|
37
|
+
|
38
|
+
def configure(conf)
|
39
|
+
super
|
40
|
+
@bind ||= conf['bind']
|
41
|
+
@topic ||= conf['topic']
|
42
|
+
@port ||= conf['port']
|
43
|
+
end
|
44
|
+
|
45
|
+
def start
|
46
|
+
#check buffer_size
|
47
|
+
@buffer.buffer_chunk_limit = available_buffer_chunk_limit
|
48
|
+
|
49
|
+
$log.debug "start mqtt #{@bind}"
|
50
|
+
opts = {host: @bind,
|
51
|
+
port: @port}
|
52
|
+
opts[:username] = @username if @username
|
53
|
+
opts[:password] = @password if @password
|
54
|
+
opts[:ssl] = @ssl if @ssl
|
55
|
+
opts[:ca_file] = @ca if @ca
|
56
|
+
opts[:cert_file] = @crt if @crt
|
57
|
+
opts[:key_file] = @key if @key
|
58
|
+
@connect = MQTT::Client.connect(opts)
|
59
|
+
super
|
60
|
+
end
|
61
|
+
|
62
|
+
def shutdown
|
63
|
+
@connect.disconnect
|
64
|
+
super
|
65
|
+
end
|
66
|
+
|
67
|
+
def format(tag, time, record)
|
68
|
+
[tag, time, record].to_msgpack
|
69
|
+
end
|
70
|
+
|
71
|
+
def write(chunk)
|
72
|
+
$log.debug "write"
|
73
|
+
chunk.msgpack_each { |tag, time, record|
|
74
|
+
@connect.publish(tag, record , retain=true)
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
# Following limits are heuristic. BSON is sometimes bigger than MessagePack and JSON.
|
80
|
+
LIMIT_MQTT = 2 * 1024 # 2048kb
|
81
|
+
|
82
|
+
def available_buffer_chunk_limit
|
83
|
+
if @buffer.buffer_chunk_limit > LIMIT_MQTT
|
84
|
+
log.warn ":buffer_chunk_limit(#{@buffer.buffer_chunk_limit}) is large. Reset :buffer_chunk_limit with #{LIMIT_MQTT}"
|
85
|
+
LIMIT_MQTT
|
86
|
+
else
|
87
|
+
@buffer.buffer_chunk_limit
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mqtt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuuna Kurita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mqtt
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- Rakefile
|
109
109
|
- fluent-plugin-mqtt.gemspec
|
110
110
|
- lib/fluent/plugin/in_mqtt.rb
|
111
|
+
- lib/fluent/plugin/out_mqtt.rb
|
111
112
|
- test/helper.rb
|
112
113
|
- test/plugin/test_in_mqtt.rb
|
113
114
|
homepage: http://github.com/yuuna/fluent-plugin-mqtt
|
@@ -130,10 +131,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
131
|
version: '0'
|
131
132
|
requirements: []
|
132
133
|
rubyforge_project:
|
133
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.4.5.1
|
134
135
|
signing_key:
|
135
136
|
specification_version: 4
|
136
137
|
summary: fluentd input plugin for mqtt server
|
137
138
|
test_files:
|
138
139
|
- test/helper.rb
|
139
140
|
- test/plugin/test_in_mqtt.rb
|
141
|
+
has_rdoc:
|