fluent-plugin-mqtt-io 0.3.8 → 0.3.9
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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/fluent-plugin-mqtt-io.gemspec +1 -1
- data/lib/fluent/plugin/mqtt_proxy.rb +19 -16
- data/lib/fluent/plugin/out_mqtt.rb +1 -0
- data/test/plugin/test_in_mqtt.rb +18 -1
- data/test/plugin/test_out_mqtt.rb +21 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3782aca018e523e428d463853e6bab8419f005ca
|
4
|
+
data.tar.gz: bec45595691338a9c383bb41925d14bf8815b685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfb2568422ebd1239ab1f50d59d9238fd0e8ccf71bd5bfe2e84487ac93580f9ab1990d64a519ae2751fd78bf7066e8258925656528e33fb79b910e2502c887af
|
7
|
+
data.tar.gz: 9eba2f2086abd8f94995248e032d76aae10fe5f3a3ca204a28a1d0e752288464aca0e08ebcf9525223b706aedfc3e73a47947a60ad38c4c265bc159a6699497c
|
data/README.md
CHANGED
@@ -63,6 +63,7 @@ The default MQTT topic is "#". Configurable options are the following:
|
|
63
63
|
|
64
64
|
- **host**: IP address of MQTT broker
|
65
65
|
- **port**: Port number of MQTT broker
|
66
|
+
- **client_id**: Client ID that to connect to MQTT broker
|
66
67
|
- **format** (mandatory): Input parser can be chosen, e.g. json, xml
|
67
68
|
- In order to use xml format, you need to install [fluent-plugin-xml-parser](https://github.com/toyokazu/fluent-plugin-xml-parser).
|
68
69
|
- Default time_key field for json format is 'time'
|
@@ -10,6 +10,8 @@ module Fluent::Plugin
|
|
10
10
|
base.config_param :host, :string, default: '127.0.0.1'
|
11
11
|
base.desc 'The port to connect to.'
|
12
12
|
base.config_param :port, :integer, default: MQTT_PORT
|
13
|
+
base.desc 'Client ID of MQTT Connection'
|
14
|
+
base.config_param :client_id, :string, default: nil
|
13
15
|
base.desc 'Specify keep alive interval.'
|
14
16
|
base.config_param :keep_alive, :integer, default: 15
|
15
17
|
base.desc 'Specify initial connection retry interval.'
|
@@ -21,19 +23,19 @@ module Fluent::Plugin
|
|
21
23
|
|
22
24
|
base.config_section :security, required: false, multi: false do
|
23
25
|
### User based authentication
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
desc 'The username for authentication'
|
27
|
+
config_param :username, :string, default: nil
|
28
|
+
desc 'The password for authentication'
|
29
|
+
config_param :password, :string, default: nil
|
30
|
+
desc 'Use TLS or not.'
|
31
|
+
config_param :use_tls, :bool, default: nil
|
32
|
+
config_section :tls, required: false, multi: false do
|
33
|
+
desc 'Specify TLS ca file.'
|
34
|
+
config_param :ca_file, :string, default: nil
|
35
|
+
desc 'Specify TLS key file.'
|
36
|
+
config_param :key_file, :string, default: nil
|
37
|
+
desc 'Specify TLS cert file.'
|
38
|
+
config_param :cert_file, :string, default: nil
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -51,11 +53,12 @@ module Fluent::Plugin
|
|
51
53
|
opts = {
|
52
54
|
host: @host,
|
53
55
|
port: @port,
|
56
|
+
client_id: @client_id,
|
54
57
|
keep_alive: @keep_alive
|
55
58
|
}
|
56
|
-
opts[:username] = @security.username if @security.
|
57
|
-
opts[:password] = @security.password if @security.
|
58
|
-
if @security.
|
59
|
+
opts[:username] = @security.username if @security.to_h.has_key?(:username)
|
60
|
+
opts[:password] = @security.password if @security.to_h.has_key?(:password)
|
61
|
+
if @security.to_h.has_key?(:use_tls) && @security.use_tls
|
59
62
|
opts[:ssl] = @security.use_tls
|
60
63
|
opts[:ca_file] = @security.tls.ca_file
|
61
64
|
opts[:cert_file] = @security.tls.cert_file
|
data/test/plugin/test_in_mqtt.rb
CHANGED
@@ -11,7 +11,7 @@ class MqttInputTest < Test::Unit::TestCase
|
|
11
11
|
CONFIG = %[
|
12
12
|
]
|
13
13
|
|
14
|
-
def create_driver(conf = CONFIG, opts = {})
|
14
|
+
def create_driver(conf = CONFIG, opts = {})
|
15
15
|
Fluent::Test::Driver::Input.new(Fluent::Plugin::MqttInput, opts: opts).configure(conf)
|
16
16
|
end
|
17
17
|
|
@@ -20,13 +20,30 @@ class MqttInputTest < Test::Unit::TestCase
|
|
20
20
|
d = create_driver %[
|
21
21
|
host 127.0.0.1
|
22
22
|
port 1300
|
23
|
+
client_id aa-bb-cc-dd
|
23
24
|
<parse>
|
24
25
|
@type json
|
25
26
|
time_format %FT%T%:z
|
26
27
|
</parse>
|
28
|
+
<security>
|
29
|
+
use_tls true
|
30
|
+
<tls>
|
31
|
+
ca_file /cert/cacert.pem
|
32
|
+
key_file /cert/private.key
|
33
|
+
cert_file /cert/cert.pem
|
34
|
+
</tls>
|
35
|
+
</security>
|
36
|
+
|
27
37
|
]
|
28
38
|
assert_equal '127.0.0.1', d.instance.host
|
29
39
|
assert_equal 1300, d.instance.port
|
40
|
+
assert_equal 'aa-bb-cc-dd', d.instance.client_id
|
41
|
+
|
42
|
+
assert_equal true, d.instance.security.use_tls
|
43
|
+
assert_equal '/cert/cacert.pem', d.instance.security.tls.ca_file
|
44
|
+
assert_equal '/cert/private.key', d.instance.security.tls.key_file
|
45
|
+
assert_equal '/cert/cert.pem', d.instance.security.tls.cert_file
|
46
|
+
|
30
47
|
end
|
31
48
|
end
|
32
49
|
end
|
@@ -11,7 +11,7 @@ class MqttOutputTest < Test::Unit::TestCase
|
|
11
11
|
CONFIG = %[
|
12
12
|
]
|
13
13
|
|
14
|
-
def create_driver(conf = CONFIG, opts = {})
|
14
|
+
def create_driver(conf = CONFIG, opts = {})
|
15
15
|
Fluent::Test::Driver::Output.new(Fluent::Plugin::MqttOutput, opts: opts).configure(conf)
|
16
16
|
end
|
17
17
|
|
@@ -20,12 +20,31 @@ class MqttOutputTest < Test::Unit::TestCase
|
|
20
20
|
d = create_driver %[
|
21
21
|
host 127.0.0.1
|
22
22
|
port 1300
|
23
|
+
client_id aa-bb-cc-dd
|
23
24
|
<format>
|
24
25
|
@type json
|
25
26
|
</format>
|
27
|
+
<monitor>
|
28
|
+
send_time true
|
29
|
+
</monitor>
|
30
|
+
<security>
|
31
|
+
use_tls true
|
32
|
+
<tls>
|
33
|
+
ca_file /cert/cacert.pem
|
34
|
+
key_file /cert/private.key
|
35
|
+
cert_file /cert/cert.pem
|
36
|
+
</tls>
|
37
|
+
</security>
|
26
38
|
]
|
27
39
|
assert_equal '127.0.0.1', d.instance.host
|
28
40
|
assert_equal 1300, d.instance.port
|
29
|
-
|
41
|
+
assert_equal true, d.instance.monitor.send_time
|
42
|
+
assert_equal 'aa-bb-cc-dd', d.instance.client_id
|
43
|
+
|
44
|
+
assert_equal true, d.instance.security.use_tls
|
45
|
+
assert_equal '/cert/cacert.pem', d.instance.security.tls.ca_file
|
46
|
+
assert_equal '/cert/private.key', d.instance.security.tls.key_file
|
47
|
+
assert_equal '/cert/cert.pem', d.instance.security.tls.cert_file
|
48
|
+
end
|
30
49
|
end
|
31
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mqtt-io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toyokazu Akiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: []
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|