fluent-plugin-ping-message 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.pryrc +3 -0
- data/README.md +1 -1
- data/Rakefile +10 -0
- data/fluent-plugin-ping-message.gemspec +5 -1
- data/lib/fluent/plugin/in_ping_message.rb +5 -0
- data/lib/fluent/plugin/out_ping_message_checker.rb +16 -3
- data/test/helper.rb +2 -1
- data/test/plugin/test_out_ping_message_checker.rb +93 -0
- metadata +59 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4590741934c3f800f8cd3f65622b74f6408245ad
|
4
|
+
data.tar.gz: f97a6947379d8d9ace320234b4dc0b12c22089bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d633f0d812bdd513b4c7c9aa56f056bab8546659439c61f08a2f448fc093ad8a10fd5dd1cb41de666d900e5918ffda047cb65b075c019bf173756457a6c418ad
|
7
|
+
data.tar.gz: 6ded881210049fa94d42ea59e877c79cb5b106b7d73cc7a5f9949c6444f7ff733dbf63745f5d7af6a481ef70fb9390630dea18a6bf4f5b4bf2002794088fa599
|
data/.pryrc
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-ping-message"
|
4
|
-
gem.version = "0.1.
|
4
|
+
gem.version = "0.1.1"
|
5
5
|
gem.authors = ["TAGOMORI Satoshi"]
|
6
6
|
gem.email = ["tagomoris@gmail.com"]
|
7
7
|
gem.description = %q{for heartbeat monitoring of Fluentd processes}
|
8
8
|
gem.summary = %q{Fluentd plugin to send/check ping messages}
|
9
9
|
gem.homepage = "https://github.com/tagomoris/fluent-plugin-ping-message"
|
10
|
+
gem.license = "APLv2"
|
10
11
|
|
11
12
|
gem.files = `git ls-files`.split($\)
|
12
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -15,4 +16,7 @@ Gem::Specification.new do |gem|
|
|
15
16
|
|
16
17
|
gem.add_runtime_dependency "fluentd"
|
17
18
|
gem.add_runtime_dependency "fluent-mixin-config-placeholders"
|
19
|
+
gem.add_development_dependency "rake"
|
20
|
+
gem.add_development_dependency "pry"
|
21
|
+
gem.add_development_dependency "pry-nav"
|
18
22
|
end
|
@@ -3,6 +3,11 @@ require 'fluent/mixin/config_placeholders'
|
|
3
3
|
class Fluent::PingMessageInput < Fluent::Input
|
4
4
|
Fluent::Plugin.register_input('ping_message', self)
|
5
5
|
|
6
|
+
# Define `log` method for v0.10.42 or earlier
|
7
|
+
unless method_defined?(:log)
|
8
|
+
define_method("log") { $log }
|
9
|
+
end
|
10
|
+
|
6
11
|
include Fluent::Mixin::ConfigPlaceholders
|
7
12
|
|
8
13
|
config_param :tag, :string, :default => 'ping'
|
@@ -3,6 +3,11 @@ require 'fluent/mixin/config_placeholders'
|
|
3
3
|
class Fluent::PingMessageCheckerOutput < Fluent::Output
|
4
4
|
Fluent::Plugin.register_output('ping_message_checker', self)
|
5
5
|
|
6
|
+
# Define `log` method for v0.10.42 or earlier
|
7
|
+
unless method_defined?(:log)
|
8
|
+
define_method("log") { $log }
|
9
|
+
end
|
10
|
+
|
6
11
|
config_param :data_field, :string, :default => 'data'
|
7
12
|
|
8
13
|
config_param :tag, :string
|
@@ -81,15 +86,21 @@ class Fluent::PingMessageCheckerOutput < Fluent::Output
|
|
81
86
|
Fluent::Engine.emit(@tag, Fluent::Engine.now, {@data_field => data})
|
82
87
|
end
|
83
88
|
end
|
89
|
+
|
90
|
+
notifications
|
84
91
|
end
|
85
92
|
|
86
93
|
def watch
|
87
94
|
@last_checked = Fluent::Engine.now
|
88
95
|
loop do
|
89
96
|
sleep 1
|
90
|
-
|
91
|
-
|
92
|
-
|
97
|
+
begin
|
98
|
+
if Fluent::Engine.now - @last_checked >= @check_interval
|
99
|
+
check_and_flush()
|
100
|
+
@last_checked = Fluent::Engine.now
|
101
|
+
end
|
102
|
+
rescue => e
|
103
|
+
log.warn "out_ping_message_checker: #{e.class} #{e.message} #{e.backtrace.first}"
|
93
104
|
end
|
94
105
|
end
|
95
106
|
end
|
@@ -103,5 +114,7 @@ class Fluent::PingMessageCheckerOutput < Fluent::Output
|
|
103
114
|
update_state(datalist)
|
104
115
|
|
105
116
|
chain.next
|
117
|
+
rescue => e
|
118
|
+
log.warn "out_ping_message_checker: #{e.message} #{e.class} #{e.backtrace.first}"
|
106
119
|
end
|
107
120
|
end
|
data/test/helper.rb
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class PingMessageCheckerOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
tag ping.message.checker
|
10
|
+
]
|
11
|
+
|
12
|
+
def create_driver(conf = CONFIG, tag='test.input')
|
13
|
+
Fluent::Test::OutputTestDriver.new(Fluent::PingMessageCheckerOutput, tag).configure(conf)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_configure
|
17
|
+
assert_nothing_raised {
|
18
|
+
d = create_driver(CONFIG)
|
19
|
+
}
|
20
|
+
assert_raise(Fluent::ConfigError) {
|
21
|
+
d = create_driver('')
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_found_not_emit
|
26
|
+
d1 = create_driver(CONFIG, 'ping.webserver')
|
27
|
+
flushed = nil
|
28
|
+
d1.run do
|
29
|
+
d1.emit({'data' => 'your.hostname.local'})
|
30
|
+
flushed = d1.instance.check_and_flush
|
31
|
+
assert_equal [], flushed
|
32
|
+
|
33
|
+
d1.emit({'data' => 'your.hostname.local'})
|
34
|
+
flushed = d1.instance.check_and_flush
|
35
|
+
assert_equal [], flushed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_missing_emit
|
40
|
+
d1 = create_driver(CONFIG, 'ping.webserver')
|
41
|
+
flushed = nil
|
42
|
+
d1.run do
|
43
|
+
d1.emit({'data' => 'your.hostname.local'})
|
44
|
+
flushed = d1.instance.check_and_flush
|
45
|
+
assert_equal [], flushed
|
46
|
+
|
47
|
+
flushed = d1.instance.check_and_flush
|
48
|
+
assert_equal 'your.hostname.local', flushed.first
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_notification_times
|
53
|
+
d1 = create_driver(CONFIG + %[notification_times 3], 'ping.webserver')
|
54
|
+
flushed = nil
|
55
|
+
d1.run do
|
56
|
+
d1.emit({'data' => 'your.hostname.local'})
|
57
|
+
flushed = d1.instance.check_and_flush
|
58
|
+
assert_equal [], flushed
|
59
|
+
|
60
|
+
flushed = d1.instance.check_and_flush
|
61
|
+
assert_equal 'your.hostname.local', flushed.first
|
62
|
+
|
63
|
+
flushed = d1.instance.check_and_flush
|
64
|
+
assert_equal 'your.hostname.local', flushed.first
|
65
|
+
|
66
|
+
flushed = d1.instance.check_and_flush
|
67
|
+
assert_equal 'your.hostname.local', flushed.first
|
68
|
+
|
69
|
+
flushed = d1.instance.check_and_flush
|
70
|
+
assert_equal [], flushed
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_recovery
|
75
|
+
d1 = create_driver(CONFIG + %[notification_times 3], 'ping.webserver')
|
76
|
+
flushed = nil
|
77
|
+
d1.run do
|
78
|
+
d1.emit({'data' => 'your.hostname.local'})
|
79
|
+
flushed = d1.instance.check_and_flush
|
80
|
+
assert_equal [], flushed
|
81
|
+
|
82
|
+
flushed = d1.instance.check_and_flush
|
83
|
+
assert_equal 'your.hostname.local', flushed.first
|
84
|
+
|
85
|
+
flushed = d1.instance.check_and_flush
|
86
|
+
assert_equal 'your.hostname.local', flushed.first
|
87
|
+
|
88
|
+
d1.emit({'data' => 'your.hostname.local'})
|
89
|
+
flushed = d1.instance.check_and_flush
|
90
|
+
assert_equal [], flushed
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,46 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-ping-message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- TAGOMORI Satoshi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: fluentd
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: fluent-mixin-config-placeholders
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-nav
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
44
81
|
- !ruby/object:Gem::Version
|
45
82
|
version: '0'
|
46
83
|
description: for heartbeat monitoring of Fluentd processes
|
@@ -50,7 +87,8 @@ executables: []
|
|
50
87
|
extensions: []
|
51
88
|
extra_rdoc_files: []
|
52
89
|
files:
|
53
|
-
- .gitignore
|
90
|
+
- ".gitignore"
|
91
|
+
- ".pryrc"
|
54
92
|
- Gemfile
|
55
93
|
- LICENSE.txt
|
56
94
|
- README.md
|
@@ -59,29 +97,31 @@ files:
|
|
59
97
|
- lib/fluent/plugin/in_ping_message.rb
|
60
98
|
- lib/fluent/plugin/out_ping_message_checker.rb
|
61
99
|
- test/helper.rb
|
100
|
+
- test/plugin/test_out_ping_message_checker.rb
|
62
101
|
homepage: https://github.com/tagomoris/fluent-plugin-ping-message
|
63
|
-
licenses:
|
102
|
+
licenses:
|
103
|
+
- APLv2
|
104
|
+
metadata: {}
|
64
105
|
post_install_message:
|
65
106
|
rdoc_options: []
|
66
107
|
require_paths:
|
67
108
|
- lib
|
68
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
110
|
requirements:
|
71
|
-
- -
|
111
|
+
- - ">="
|
72
112
|
- !ruby/object:Gem::Version
|
73
113
|
version: '0'
|
74
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
-
none: false
|
76
115
|
requirements:
|
77
|
-
- -
|
116
|
+
- - ">="
|
78
117
|
- !ruby/object:Gem::Version
|
79
118
|
version: '0'
|
80
119
|
requirements: []
|
81
120
|
rubyforge_project:
|
82
|
-
rubygems_version:
|
121
|
+
rubygems_version: 2.2.2
|
83
122
|
signing_key:
|
84
|
-
specification_version:
|
123
|
+
specification_version: 4
|
85
124
|
summary: Fluentd plugin to send/check ping messages
|
86
125
|
test_files:
|
87
126
|
- test/helper.rb
|
127
|
+
- test/plugin/test_out_ping_message_checker.rb
|