logstash-output-snmptrap-v2 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8f5c8c3efac1f786b630caca249fcee08595409a5b25ed1f44865eabc4081094
4
+ data.tar.gz: f2a554fa7c56fbad6017ab5896e66ac45b7ecd944519a6022c91861e60415707
5
+ SHA512:
6
+ metadata.gz: f9c594258869f90e87afb7934a9f033d832e13adb818f486ee0c22911ad1013906c7c763c4b175571c4bf33c8f8a90558f54e4d80ee66631a0244fc39a804b3e
7
+ data.tar.gz: 27a8e6bc9af655033a01583bd6d19fdf01e8e5d5731d6c5dc144054d11499edb4bd90677727ded50f2f14b871f1fb242eaf4632fd1682c843d61bd372f026cb8
@@ -0,0 +1,6 @@
1
+ Contributors:
2
+ Ryan O'Keeffe (DanielRedOak)
3
+ Elmar Vonlanthen (Elmux)
4
+ chrisbentz
5
+ Pieter Baele (Fiddich)
6
+ Marcel Vingerling
@@ -0,0 +1,2 @@
1
+ # logstash-output-snmp
2
+ SNMP output plugin.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
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.
@@ -0,0 +1,94 @@
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
+ ## logstash-output-snmptrap ##
9
+
10
+ SNMP Trap v2c Output for Logstash
11
+
12
+ #Synopsis
13
+ ```
14
+ output {
15
+ snmptrap {
16
+ codec => ... # codec (optional), default: "line"
17
+ host => ... # string (optional), default: "0.0.0.0"
18
+ port => ... # number (optional), default: "162"
19
+ community => ... # string (optional), default: "public"
20
+ oid => ... # string (required)
21
+ yamlmibdir => ... # string (optional)
22
+ }
23
+ }
24
+ ```
25
+
26
+ ## Developing
27
+
28
+ ### 1. Plugin Developement and Testing
29
+
30
+ #### Code
31
+ - To get started, you'll need JRuby with the Bundler gem installed.
32
+
33
+ - 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).
34
+
35
+ - Install dependencies
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ #### Test
41
+
42
+ - Update your dependencies
43
+
44
+ ```sh
45
+ bundle install
46
+ ```
47
+
48
+ - Run tests
49
+
50
+ ```sh
51
+ bundle exec rspec
52
+ ```
53
+
54
+ ### 2. Running your unpublished Plugin in Logstash
55
+
56
+ #### 2.1 Run in a local Logstash clone
57
+
58
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
59
+ ```ruby
60
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
61
+ ```
62
+ - Install plugin
63
+ ```sh
64
+ bin/plugin install --no-verify
65
+ ```
66
+ - Run Logstash with your plugin
67
+ ```sh
68
+ bin/logstash -e 'filter {awesome {}}'
69
+ ```
70
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
71
+
72
+ #### 2.2 Run in an installed Logstash
73
+
74
+ 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:
75
+
76
+ - Build your plugin gem
77
+ ```sh
78
+ gem build logstash-filter-awesome.gemspec
79
+ ```
80
+ - Install the plugin from the Logstash home
81
+ ```sh
82
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
83
+ ```
84
+ - Start Logstash and proceed to test the plugin
85
+
86
+ ## Contributing
87
+
88
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
89
+
90
+ 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.
91
+
92
+ It is more important to the community that you are able to contribute.
93
+
94
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+
5
+ # An example output that does nothing.
6
+ class LogStash::Outputs::Snmptrap < LogStash::Outputs::Base
7
+ config_name "snmptrap"
8
+
9
+ default :codec, "line"
10
+
11
+ #address of the host to send the trap/notification to
12
+ config :host, :validate => :string, :default => "127.0.0.1"
13
+
14
+ #the port to send the trap on
15
+ config :port, :validate => :number, :default => 162
16
+
17
+ #the community string to include
18
+ config :community, :validate => :string, :default => "public"
19
+
20
+ #the OID that specifies the event generating the trap message
21
+ config :oid, :validate => :string, :required => true
22
+
23
+ # varbind configuration
24
+ config :varbinds, :default => {"@oid" => "!event.to_s"}
25
+
26
+ def initialize(*args)
27
+ super(*args)
28
+ end
29
+
30
+ public
31
+ def register
32
+ require "snmp"
33
+
34
+ @codec.on_event do |event|
35
+
36
+ #set some variables for the trap sender
37
+ trapsender_opts = {:trap_port => @port, :host => @host, :community => @community }
38
+
39
+ #prep and do the full send
40
+ SNMP::Manager.open(trapsender_opts) do |snmp|
41
+ #set it up and send the whole event using the user specified codec
42
+ varbinds = []
43
+ @varbinds.each do |key, value|
44
+ if value.start_with?("!")
45
+ value.delete_prefix!("!")
46
+ value = eval(value)
47
+ elsif value.start_with?("@")
48
+ value.delete_prefix!("@")
49
+ value = event.get(value)
50
+ end
51
+ if value.is_a? String
52
+ varbinds << SNMP::VarBind.new(key, SNMP::OctetString.new(value.force_encoding('ASCII-8BIT')))
53
+ elsif value.is_a? Integer
54
+ varbinds << SNMP::VarBind.new(key, SNMP::Integer.new(value))
55
+ end
56
+ end
57
+
58
+ #we dont actually care about the sys_up_time...do we.
59
+ snmp.trap_v2(0, @oid, varbinds)
60
+ end
61
+ end
62
+ end
63
+
64
+ public
65
+ def receive(event)
66
+ return unless output?(event)
67
+ if event == LogStash::SHUTDOWN
68
+ finished
69
+ return
70
+ end
71
+ @oid = event.sprintf(@oid)
72
+ @codec.encode(event)
73
+ end
74
+ end
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-snmptrap-v2'
3
+ s.version = '0.9.3'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = 'SNMP Output for Logstash'
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.homepage = 'https://github.com/sjaek/logstash-output-snmptrap'
8
+ s.authors = ['Marcel Vingerling']
9
+ s.email = 'marcel.vingerling@gmail.com'
10
+ s.require_paths = ['lib']
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
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" => "output" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
22
+ s.add_runtime_dependency "logstash-codec-plain"
23
+ s.add_development_dependency "logstash-devutils"
24
+ end
@@ -0,0 +1,21 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/outputs/example"
3
+ require "logstash/codecs/plain"
4
+ require "logstash/event"
5
+
6
+ describe LogStash::Outputs::Example do
7
+ let(:sample_event) { LogStash::Event.new }
8
+ let(:output) { LogStash::Outputs::Example.new }
9
+
10
+ before do
11
+ output.register
12
+ end
13
+
14
+ describe "receive message" do
15
+ subject { output.receive(sample_event) }
16
+
17
+ it "returns a string" do
18
+ expect(subject).to eq("Event received")
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-snmptrap-v2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.3
5
+ platform: ruby
6
+ authors:
7
+ - Marcel Vingerling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
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
+ name: logstash-codec-plain
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: logstash-devutils
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
+ description: This gem is a logstash plugin required to be installed on top of the
56
+ Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
57
+ a stand-alone program
58
+ email: marcel.vingerling@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - CONTRIBUTORS
64
+ - DEVELOPER.md
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - lib/logstash/outputs/snmptrap.rb
69
+ - logstash-output-snmptrap.gemspec
70
+ - spec/outputs/snmptrap_spec.rb
71
+ homepage: https://github.com/sjaek/logstash-output-snmptrap
72
+ licenses:
73
+ - Apache-2.0
74
+ metadata:
75
+ logstash_plugin: 'true'
76
+ logstash_group: output
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.7.6
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: SNMP Output for Logstash
97
+ test_files:
98
+ - spec/outputs/snmptrap_spec.rb