logstash-output-snmptrap 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTORS +6 -0
- data/DEVELOPER.md +2 -0
- data/Gemfile +2 -0
- data/LICENSE +13 -0
- data/README.md +94 -0
- data/lib/logstash/outputs/snmptrap.rb +73 -0
- data/logstash-output-snmptrap.gemspec +24 -0
- data/spec/outputs/snmptrap_spec.rb +21 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5836098b934d334b9f965941144acd1055c200a
|
4
|
+
data.tar.gz: 9d011f962c9ae6dcef3b7a6db36cda61fabfffd4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b8e7f1321d0134dd700ad7324e54a098cf994d4cffed86ee6f2b0dc2669c89cb6bd39463b2a99c04a741bb9756c1fd3fa57dd9e1a7de2ce0fb21ffe317a681b
|
7
|
+
data.tar.gz: bf335fd0334b333fb26ada7152e9cee59f8c3e44d6459c285018b3593b577384ee214c9919d2afb286dd0172ea24481fafa5348b34867495be84047321efa984
|
data/CONTRIBUTORS
ADDED
data/DEVELOPER.md
ADDED
data/Gemfile
ADDED
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/README.md
ADDED
@@ -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,73 @@
|
|
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
|
+
# directory of YAML MIB maps (same format ruby-snmp uses)
|
24
|
+
config :yamlmibdir, :validate => :string
|
25
|
+
|
26
|
+
def initialize(*args)
|
27
|
+
super(*args)
|
28
|
+
end
|
29
|
+
|
30
|
+
public
|
31
|
+
def register
|
32
|
+
require "snmp"
|
33
|
+
#from snmp trap input plugin, thanks
|
34
|
+
# if @yamlmibdir
|
35
|
+
# @logger.info("checking #{@yamlmibdir} for MIBs")
|
36
|
+
# Dir["#{@yamlmibdir}/*.yaml"].each do |yamlfile|
|
37
|
+
# mib_name = File.basename(yamlfile, ".*")
|
38
|
+
# @yaml_mibs ||= []
|
39
|
+
# @yaml_mibs << mib_name
|
40
|
+
# end
|
41
|
+
# @logger.info("found MIBs: #{@yaml_mibs.join(',')}") if @yaml_mibs
|
42
|
+
# end
|
43
|
+
@codec.on_event do |event|
|
44
|
+
|
45
|
+
#set some variables for the trap sender
|
46
|
+
trapsender_opts = {:trap_port => @port, :host => @host, :community => @community }
|
47
|
+
|
48
|
+
#check for and add user specified mibs
|
49
|
+
# if @yaml_mibs && !@yaml_mibs.empty?
|
50
|
+
# trapsender_opts.merge!({:mib_dir => @yamlmibdir, :mib_modules => @yaml_mibs})
|
51
|
+
# end
|
52
|
+
#prep and do the full send
|
53
|
+
SNMP::Manager.open(trapsender_opts) do |snmp|
|
54
|
+
#set it up and send the whole event using the user specified codec
|
55
|
+
varbind = SNMP::VarBind.new(@oid, SNMP::OctetString.new(event.to_s))
|
56
|
+
|
57
|
+
#we dont actually care about the sys_up_time...do we. Also I am re-using the oid that was input.
|
58
|
+
snmp.trap_v2(0, @oid, varbind)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
public
|
64
|
+
def receive(event)
|
65
|
+
return unless output?(event)
|
66
|
+
if event == LogStash::SHUTDOWN
|
67
|
+
finished
|
68
|
+
return
|
69
|
+
end
|
70
|
+
@oid = event.sprintf(@oid)
|
71
|
+
@codec.encode(event)
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-output-snmptrap'
|
3
|
+
s.version = '0.9.2'
|
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/Fiddich/logstash-output-snmptrap'
|
8
|
+
s.authors = ['Pieter Baele']
|
9
|
+
s.email = 'pieter.baele@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,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-output-snmptrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pieter Baele
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-12 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-codec-plain
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: logstash-devutils
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
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 Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
56
|
+
email: pieter.baele@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- CONTRIBUTORS
|
62
|
+
- DEVELOPER.md
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE
|
65
|
+
- README.md
|
66
|
+
- lib/logstash/outputs/snmptrap.rb
|
67
|
+
- logstash-output-snmptrap.gemspec
|
68
|
+
- spec/outputs/snmptrap_spec.rb
|
69
|
+
homepage: https://github.com/Fiddich/logstash-output-snmptrap
|
70
|
+
licenses:
|
71
|
+
- Apache-2.0
|
72
|
+
metadata:
|
73
|
+
logstash_plugin: 'true'
|
74
|
+
logstash_group: output
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.6.8
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: SNMP Output for Logstash
|
95
|
+
test_files:
|
96
|
+
- spec/outputs/snmptrap_spec.rb
|