logstash-output-progress 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/LICENSE +13 -0
- data/Rakefile +7 -0
- data/lib/logstash/outputs/progress.rb +86 -0
- data/logstash-output-progress.gemspec +27 -0
- data/spec/outputs/progress_spec.rb +5 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38f78af7e4cd794aa159dbe798dfedbb1ee8d9ca
|
4
|
+
data.tar.gz: 7b83b2f7ddf3f98f701153060958d2a022238e09
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b994f1f6b3c95c213cfccf7e4301dc21224920d0ece86abe1d3da0bef6320f566ac65f378406faeb1ab4ef76ed2f966160cd510e2915126e49fb4af28475c009
|
7
|
+
data.tar.gz: ec61a645e1c5395131e522826aeb58f4fa8b5979e2aa46ce4c09201aaa7ef0203f8b045f105cb40dd86eaed6b7abf1a856085fc6975d90d33894eaa8be8e8cb0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/Rakefile
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require "logstash/namespace"
|
2
|
+
require "logstash/outputs/base"
|
3
|
+
|
4
|
+
# File output.
|
5
|
+
#
|
6
|
+
# Write since_db-file with progress
|
7
|
+
class LogStash::Outputs::Progress < LogStash::Outputs::Base
|
8
|
+
|
9
|
+
config_name "progress"
|
10
|
+
|
11
|
+
|
12
|
+
# The format to use when writing events to the file. This value
|
13
|
+
# supports any string and can include %{name} and other dynamic
|
14
|
+
# strings.
|
15
|
+
#
|
16
|
+
# If this setting is omitted, the full json representation of the
|
17
|
+
# event will be written as a single line.
|
18
|
+
config :message_format, :validate => :string
|
19
|
+
|
20
|
+
# Where to write the progress database (keeps track of the current
|
21
|
+
# position of monitored log files). The default will write
|
22
|
+
# progressdb files to some path matching "$HOME/.sincedb*"
|
23
|
+
config :progressdb_path, :validate => :string
|
24
|
+
|
25
|
+
|
26
|
+
public
|
27
|
+
def register
|
28
|
+
require "fileutils" # For mkdir_p
|
29
|
+
|
30
|
+
workers_not_supported
|
31
|
+
@sincedb = {}
|
32
|
+
end # def register
|
33
|
+
|
34
|
+
public
|
35
|
+
def receive(event)
|
36
|
+
return unless output?(event)
|
37
|
+
|
38
|
+
if @message_format
|
39
|
+
output = event.sprintf(@message_format)
|
40
|
+
else
|
41
|
+
output = event.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
ino, dev_major, dev_minor, size, pos = event["message"].split(" ", 5)
|
45
|
+
|
46
|
+
inode = [ino.to_i, dev_major.to_i, dev_minor.to_i, size.to_i]
|
47
|
+
|
48
|
+
if event.include? "tags" and event["tags"].include?("del")
|
49
|
+
@sincedb.delete(inode)
|
50
|
+
else
|
51
|
+
@sincedb[inode] = output
|
52
|
+
end
|
53
|
+
_sincedb_write(event["path"])
|
54
|
+
|
55
|
+
end # def receive
|
56
|
+
|
57
|
+
private
|
58
|
+
def _sincedb_write(event_path)
|
59
|
+
path = @progressdb_path
|
60
|
+
tmp = "#{path}.new"
|
61
|
+
begin
|
62
|
+
db = File.open(tmp, "w")
|
63
|
+
rescue => e
|
64
|
+
@logger.warn("_sincedb_write failed: #{tmp}: #{e}")
|
65
|
+
return
|
66
|
+
end
|
67
|
+
|
68
|
+
@sincedb.each do |inode, message|
|
69
|
+
db.puts([message].flatten.join(" "))
|
70
|
+
end
|
71
|
+
db.close
|
72
|
+
|
73
|
+
begin
|
74
|
+
File.rename(tmp, path)
|
75
|
+
rescue => e
|
76
|
+
@logger.warn("_sincedb_write rename/sync failed: #{tmp} -> #{path}: #{e}")
|
77
|
+
end
|
78
|
+
end # def _sincedb_write
|
79
|
+
|
80
|
+
def teardown
|
81
|
+
@logger.debug("Teardown: closing files")
|
82
|
+
finished
|
83
|
+
end
|
84
|
+
end # class LogStash::Outputs::File
|
85
|
+
|
86
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
|
3
|
+
s.name = 'logstash-output-progress'
|
4
|
+
s.version = '0.1.0'
|
5
|
+
s.licenses = ['Apache License (2.0)']
|
6
|
+
s.summary = "Write since_db-file with progress."
|
7
|
+
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
8
|
+
s.authors = ["Signify"]
|
9
|
+
s.email = 'dietmar@signifydata.com'
|
10
|
+
s.homepage = "http://www.signifydata.com"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = `git ls-files`.split($\)
|
15
|
+
|
16
|
+
# Tests
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
|
19
|
+
# Special flag to let us know this is actually a logstash plugin
|
20
|
+
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
21
|
+
|
22
|
+
# Gem dependencies
|
23
|
+
s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0'
|
24
|
+
|
25
|
+
s.add_development_dependency 'logstash-devutils'
|
26
|
+
end
|
27
|
+
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-progress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Signify
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 1.4.0
|
19
|
+
- - <
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.4.0
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
name: logstash-devutils
|
40
|
+
prerelease: false
|
41
|
+
type: :development
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
48
|
+
email: dietmar@signifydata.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- Rakefile
|
57
|
+
- lib/logstash/outputs/progress.rb
|
58
|
+
- logstash-output-progress.gemspec
|
59
|
+
- spec/outputs/progress_spec.rb
|
60
|
+
homepage: http://www.signifydata.com
|
61
|
+
licenses:
|
62
|
+
- Apache License (2.0)
|
63
|
+
metadata:
|
64
|
+
logstash_plugin: 'true'
|
65
|
+
logstash_group: output
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.1.9
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Write since_db-file with progress.
|
86
|
+
test_files:
|
87
|
+
- spec/outputs/progress_spec.rb
|