logstash-input-sttxml1 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd898f801a66f3435c73cf33f3baa908af3ee312
4
+ data.tar.gz: d8990000f7ce007e1fd0a61288d3056bf6874f74
5
+ SHA512:
6
+ metadata.gz: e62c610ec9c9a375c282d78c626999a366b2bef1e62c614f7a23176e48a21a6f63aca31110718f6dc9c06eb9d1beb01cbf75be2b654dce9d926940567f59753e
7
+ data.tar.gz: 61600e18ab78f7f8fde764c30506d6a10ec78e6a41059dcaf5415054a355ae161cd27964175d8a5d2e1c7c1f5682de3dda97ecfd6faf38525e7780aab18c8fd9
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/CHANGELOG.md ADDED
File without changes
data/DEVELOPER.md ADDED
@@ -0,0 +1,2 @@
1
+ # logstash-input-example
2
+ Example input plugin. This should help bootstrap your effort to write your own input plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ logstash-input-sttxml1 (0.0.4)
5
+ filewatcher (~> 0.5.2)
6
+ logstash-codec-plain
7
+ logstash-core (>= 1.4.0, < 2.0.0)
8
+ nokogiri (~> 1.6.6.2)
9
+ stud
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ cabin (0.7.1)
15
+ clamp (0.6.5)
16
+ coderay (1.1.0)
17
+ diff-lcs (1.2.5)
18
+ ffi (1.9.10-java)
19
+ filesize (0.0.4)
20
+ filewatcher (0.5.2)
21
+ trollop (~> 2.0)
22
+ gem_publisher (1.5.0)
23
+ gems (0.8.3)
24
+ i18n (0.6.9)
25
+ insist (1.0.0)
26
+ jrjackson (0.2.9)
27
+ kramdown (1.8.0)
28
+ logstash-codec-plain (1.0.0)
29
+ logstash-core (>= 1.4.0, < 2.0.0)
30
+ logstash-core (1.5.3-java)
31
+ cabin (~> 0.7.0)
32
+ clamp (~> 0.6.5)
33
+ filesize (= 0.0.4)
34
+ gems (~> 0.8.3)
35
+ i18n (= 0.6.9)
36
+ jrjackson (~> 0.2.9)
37
+ minitar (~> 0.5.4)
38
+ pry (~> 0.10.1)
39
+ stud (~> 0.0.19)
40
+ thread_safe (~> 0.3.5)
41
+ treetop (< 1.5.0)
42
+ logstash-devutils (0.0.15-java)
43
+ gem_publisher
44
+ insist (= 1.0.0)
45
+ kramdown
46
+ minitar
47
+ rake
48
+ rspec (~> 3.1.0)
49
+ stud (>= 0.0.20)
50
+ method_source (0.8.2)
51
+ minitar (0.5.4)
52
+ nokogiri (1.6.6.2-java)
53
+ polyglot (0.3.5)
54
+ pry (0.10.1-java)
55
+ coderay (~> 1.1.0)
56
+ method_source (~> 0.8.1)
57
+ slop (~> 3.4)
58
+ spoon (~> 0.0)
59
+ rake (10.4.2)
60
+ rspec (3.1.0)
61
+ rspec-core (~> 3.1.0)
62
+ rspec-expectations (~> 3.1.0)
63
+ rspec-mocks (~> 3.1.0)
64
+ rspec-core (3.1.7)
65
+ rspec-support (~> 3.1.0)
66
+ rspec-expectations (3.1.2)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.1.0)
69
+ rspec-mocks (3.1.3)
70
+ rspec-support (~> 3.1.0)
71
+ rspec-support (3.1.2)
72
+ slop (3.6.0)
73
+ spoon (0.0.4)
74
+ ffi
75
+ stud (0.0.20)
76
+ thread_safe (0.3.5-java)
77
+ treetop (1.4.15)
78
+ polyglot
79
+ polyglot (>= 0.3.1)
80
+ trollop (2.1.2)
81
+
82
+ PLATFORMS
83
+ java
84
+
85
+ DEPENDENCIES
86
+ logstash-devutils
87
+ logstash-input-sttxml1!
88
+
89
+ BUNDLED WITH
90
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
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/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'filter {awesome {}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rake"
@@ -0,0 +1,95 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/interval"
5
+ require "socket" # for Socket.gethostname
6
+ require "filewatcher"
7
+ require "nokogiri"
8
+
9
+ # Generate a repeating message.
10
+ #
11
+ # This plugin is intented only as an example.
12
+
13
+ class LogStash::Inputs::Sttxml1 < LogStash::Inputs::Base
14
+ config_name "sttxml1"
15
+
16
+ # If undefined, Logstash will complain, even if codec is unused.
17
+ default :codec, "plain"
18
+
19
+ # Default matches R0 and r0
20
+ config :agent_regex, :validate => :string, :default => '[rR]0'
21
+
22
+ # Default matches R1 and r1
23
+ config :customer_regex, :validate => :string, :default => '[rR]1'
24
+
25
+ # The path(s) to the file(s) to use as an input.
26
+ config :path, :validate => :array, :required => true
27
+
28
+ # How often (in seconds) we stat files to see if they have been modified.
29
+ # Increasing this interval will decrease the number of system calls we make,
30
+ # but increase the time to detect new log lines.
31
+ config :stat_interval, :validate => :number, :default => 3
32
+
33
+ public
34
+ def register
35
+ @host = Socket.gethostname
36
+ @logger.info("Registering file input", :path => @path)
37
+ end # def register
38
+
39
+ def run(queue)
40
+ FileWatcher.new(@path).watch(@stat_interval) do |filename, event|
41
+ if(event == :new)
42
+
43
+ agentRegex = /#{@agent_regex}/
44
+ customerRegex = /#{@customer_regex}/
45
+ agentParties = 0
46
+ customerParties = 0
47
+ parties = Hash.new
48
+
49
+ begin
50
+ value = File.read(filename)
51
+ doc = Nokogiri::XML(value, nil, value.encoding.to_s)
52
+ clauses = []
53
+ event = LogStash::Event.new("host" => @host)
54
+
55
+ doc.xpath("//Subject[@Name='RecognizeText']/Role").each do |link|
56
+ who = "#{link.attribute('Name').content}"
57
+ if(who=~agentRegex)
58
+ if(!parties.key?(who))
59
+ parties[who] = "agent#{agentParties}"
60
+ agentParties += 1
61
+ end
62
+ end
63
+
64
+ if(who=~customerRegex)
65
+ if(!parties.key?(who))
66
+ parties[who] = "customer#{customerParties}"
67
+ customerParties += 1
68
+ end
69
+ end
70
+ party = parties[who]
71
+ event[party] = ''
72
+ link.child.children.each do |item|
73
+ begin_time, end_time, content = item.attribute('Begin').content.to_i, item.attribute('End').content.to_i, item.child.text
74
+ event[party] += "#{party}-#{begin_time} #{content}\n"
75
+ clauses << [ who, party, begin_time, end_time, content ]
76
+ end
77
+ event['parties'] = parties.keys
78
+ event['dialogs'] = clauses.sort_by { |_, _, begin_time, _, _| begin_time }.map { |_, party, begin_time, _, content| "#{party}-#{begin_time} #{content}" }.join("\n")
79
+ event['vtt'] = (clauses.sort_by { |_, _, begin_time, _, _| begin_time }.map do |who, party, begin_time, end_time, content|
80
+ "#{party}-#{begin_time}\n#{Time.at(begin_time/1000).utc.strftime('%H:%M:%S.')}#{'%.3d' % (begin_time%1000)} --> #{Time.at(end_time/1000).utc.strftime('%H:%M:%S.')}#{'%.3d' %(end_time%1000)}\n<v #{who}>#{content}</v>\n"
81
+ end)
82
+ end
83
+
84
+ decorate(event)
85
+ queue << event
86
+ rescue => ex
87
+ @logger.warn('Trouble parsing xml', :source => @source, :exception => ex, :backtrace => ex.backtrace)
88
+ return
89
+ end
90
+ end
91
+ end
92
+
93
+ end # def run
94
+
95
+ end # class LogStash::Inputs::Sttxml1
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-sttxml1'
3
+ s.version = '0.0.5'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "This example input streams a string at a definable interval."
6
+ 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"
7
+ s.authors = ["henry"]
8
+ s.email = 'jaohaohsuan@gmail.com'
9
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
22
+ s.add_runtime_dependency 'logstash-codec-plain'
23
+ s.add_runtime_dependency 'stud'
24
+ s.add_runtime_dependency 'filewatcher', '~> 0.5.2'
25
+ s.add_runtime_dependency 'nokogiri', '~> 1.6.6.2'
26
+ s.add_development_dependency 'logstash-devutils'
27
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-sttxml1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - henry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-28 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-codec-plain
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ name: stud
54
+ prerelease: false
55
+ type: :runtime
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 0.5.2
67
+ name: filewatcher
68
+ prerelease: false
69
+ type: :runtime
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: 0.5.2
75
+ - !ruby/object:Gem::Dependency
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ~>
79
+ - !ruby/object:Gem::Version
80
+ version: 1.6.6.2
81
+ name: nokogiri
82
+ prerelease: false
83
+ type: :runtime
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 1.6.6.2
89
+ - !ruby/object:Gem::Dependency
90
+ requirement: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ name: logstash-devutils
96
+ prerelease: false
97
+ type: :development
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ 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
104
+ email: jaohaohsuan@gmail.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - .gitignore
110
+ - CHANGELOG.md
111
+ - DEVELOPER.md
112
+ - Gemfile
113
+ - Gemfile.lock
114
+ - LICENSE
115
+ - NOTICE.TXT
116
+ - README.md
117
+ - Rakefile
118
+ - lib/logstash/inputs/sttxml1.rb
119
+ - logstash-input-sttxml1.gemspec
120
+ - spec/inputs/sttxml1_spec.rb
121
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
122
+ licenses:
123
+ - Apache License (2.0)
124
+ metadata:
125
+ logstash_plugin: 'true'
126
+ logstash_group: input
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.4.5
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: This example input streams a string at a definable interval.
147
+ test_files:
148
+ - spec/inputs/sttxml1_spec.rb