logstash-filter-ros2_node_info 0.1.1

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
+ SHA256:
3
+ metadata.gz: 91999825fb3abdd377eb0ecb66ad3ea4f6544f67947f10c34757340d6e0882ed
4
+ data.tar.gz: 78ce9ff789f6067e9d9055758fa613931d0a426fd7245d117b39fbfb3b97954e
5
+ SHA512:
6
+ metadata.gz: 5a23ccdd3420ebc3bde34cf749b442bcde11efeac8770826ae560b9cf39eed511feec7c682a983b915b10c8b30a384fec977a683db1629a0f42a9a9c139c5c95
7
+ data.tar.gz: 74d2fcb2255a0ecd243c8391f3a56808ea237594e452a12e2263626eeb2e479a5bfbb2ca6be922037f96c6e38ed471388c839e692844e4bfe1a2c04bd998fa3d
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ - Plugin created with the logstash plugin generator
data/CONTRIBUTORS ADDED
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Chris Reffett - chris.reffett@soartech.com
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
data/DEVELOPER.md ADDED
@@ -0,0 +1 @@
1
+ # logstash-filter-ros2_node_info
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/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.elastic.co/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/elastic/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/logstash-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/logstash-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/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+
4
+ class LogStash::Filters::Ros2NodeInfo < LogStash::Filters::Base
5
+ #
6
+ # filter {
7
+ # ros2_node_info {
8
+ # source => "message"
9
+ # }
10
+ # }
11
+ #
12
+ config_name "ros2_node_info"
13
+ config :source, :validate => :string, :default => "message"
14
+
15
+ public
16
+ def register
17
+ # Add instance variables
18
+ end # def register
19
+
20
+ public
21
+ def filter(event)
22
+ # Essentially a simple stack-based parser based on number of spaces at
23
+ # the start of each line
24
+ if @source
25
+ last_cat = nil
26
+ running_array = []
27
+ event.get(@source).split("\n").each do |line|
28
+ # No space at the start of the line - node name
29
+ if !line.start_with?(" ")
30
+ event.set("node", line)
31
+ # Two spaces at the start of the line - category
32
+ elsif / \w/ =~ line
33
+ unless last_cat.nil?
34
+ # If we're tracking a category, dump it to the event before
35
+ # starting a new one
36
+ event.set(last_cat, running_array)
37
+ running_array = []
38
+ end
39
+ last_cat = line.tr(" ", "").tr(":", "").downcase
40
+ elsif / [A-Za-z0-9\/]/ =~ line
41
+ # Element of a category - split it appropriately and append it to the
42
+ # working array
43
+ split_line = line.tr(" ", "").split(":")
44
+ @logger.error(line)
45
+ @logger.error(split_line.to_yaml)
46
+ running_array << { "topic" => split_line[0], "type" => split_line[1] }
47
+ end
48
+ end
49
+ event.set(last_cat, running_array)
50
+ end
51
+
52
+ # filter_matched should go in the last line of our successful code
53
+ filter_matched(event)
54
+ end # def filter
55
+ end # class LogStash::Filters::Ros2NodeInfo
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-filter-ros2_node_info'
3
+ s.version = '0.1.1'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = 'A plugin to parse the output of `ros2 node info` into a useful format.'
6
+ s.homepage = 'https://github.com/soartech/logstash-filter-ros2_node_info'
7
+ s.authors = ['Chris Reffett']
8
+ s.email = 'chris.reffett@soartech.com'
9
+ s.require_paths = ['lib']
10
+
11
+ # Files
12
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
13
+ # Tests
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+
16
+ # Special flag to let us know this is actually a logstash plugin
17
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
18
+
19
+ # Gem dependencies
20
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
21
+ s.add_development_dependency 'logstash-devutils'
22
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+ require_relative '../spec_helper'
3
+ require "logstash/filters/ros2_node_info"
4
+
5
+ describe LogStash::Filters::Ros2NodeInfo do
6
+ describe "Parse valid message" do
7
+ let(:config) do <<-CONFIG
8
+ filter {
9
+ ros2_node_info {
10
+ source => "message"
11
+ }
12
+ }
13
+ CONFIG
14
+ end
15
+
16
+ sample("message" => "/talker
17
+ Subscribers:
18
+ /parameter_events: rcl_interfaces/ParameterEvent
19
+ Publishers:
20
+ /chatter: std_msgs/String
21
+ Services:
22
+ /talker/set_parameters_atomically: rcl_interfaces/SetParametersAtomically") do
23
+ expect(subject.get("node")).to eq("/talker")
24
+ expect(subject.get("services")).to eq([{"topic"=>"/talker/set_parameters_atomically",
25
+ "type"=>"rcl_interfaces/SetParametersAtomically"}])
26
+ expect(subject.get("publishers")).to eq([{"topic"=>"/chatter",
27
+ "type"=>"std_msgs/String"}])
28
+ expect(subject.get("subscribers")).to eq([{"topic"=>"/parameter_events",
29
+ "type"=>"rcl_interfaces/ParameterEvent"}])
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-filter-ros2_node_info
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Chris Reffett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-24 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: '2.0'
19
+ name: logstash-core-plugin-api
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ name: logstash-devutils
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email: chris.reffett@soartech.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CHANGELOG.md
48
+ - CONTRIBUTORS
49
+ - DEVELOPER.md
50
+ - Gemfile
51
+ - LICENSE
52
+ - README.md
53
+ - lib/logstash/filters/ros2_node_info.rb
54
+ - logstash-filter_ros2_node_info.gemspec
55
+ - spec/filters/ros2_node_info_spec.rb
56
+ - spec/spec_helper.rb
57
+ homepage: https://github.com/soartech/logstash-filter-ros2_node_info
58
+ licenses:
59
+ - Apache-2.0
60
+ metadata:
61
+ logstash_plugin: 'true'
62
+ logstash_group: filter
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.7.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: A plugin to parse the output of `ros2 node info` into a useful format.
83
+ test_files:
84
+ - spec/filters/ros2_node_info_spec.rb
85
+ - spec/spec_helper.rb