logstash-input-snmp 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13fdcfbd3e486a466a7fa32e1de3e6bbdccd30779f5eb4fce9ef8645355c8322
4
- data.tar.gz: b8e80f54fbe399f262e48aff1fd614d578b16d493cded3e15446593ebffd1f93
3
+ metadata.gz: 10af98fea9ec23b72d7b713cd503c4b34167cf5cebd494f4e73e52f5b02a12c1
4
+ data.tar.gz: f009f89f26dc5b8fff9d3fa07dacd577999c13589a175417178db1219063c98c
5
5
  SHA512:
6
- metadata.gz: fc44139cfc59066ffa89fc916903e4507972b9650cc056ee0bb897a8028dcf93abf30c07627926ce717a0da275d084ebf45b7e631355d04752ef55e868eef3f7
7
- data.tar.gz: 1ca064497bd573c6d3de4c00bf0d744fb14339926d61203d6a7e74fcbb6887c64f784e32ecb579db11fc2ff849c329b7479df92a44b24803d653b316ab41cbd6
6
+ metadata.gz: 1db41b3f534bac5a03dbfd45210ebe2e944b361029d80e1bcc1131c4b1e35f363b72c07ad7771a3c54eca21c31b67e11fac8a725bcabd0b31e11a68bdbecdbdd
7
+ data.tar.gz: ece59ff5c72ccea90e8223fed33978ed4a7b6d486928d6c63eaf8f5696d85ec41e3a352ead03e6bcdb9abca8ae60a9fe5da6908f1a1cb43ea72666461b13cd8a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.3.3
2
+ - Silence warnings when loading dictionary MIB files [#118](https://github.com/logstash-plugins/logstash-input-snmp/pull/118)
3
+
4
+ ## 1.3.2
5
+ - [DOC] Add troubleshooting help for "failed to locate MIB module" error when using smidump to convert MIBs [#112](https://github.com/logstash-plugins/logstash-input-snmp/pull/112)
6
+ - Fix CI failures [#113](https://github.com/logstash-plugins/logstash-input-snmp/pull/113)
7
+
1
8
  ## 1.3.1
2
9
  - Refactor: handle no response(s) wout error logging [#105](https://github.com/logstash-plugins/logstash-input-snmp/pull/105)
3
10
 
@@ -12,7 +19,7 @@
12
19
  - Added integration tests to ensure SNMP server and IPv6 connections [#90](https://github.com/logstash-plugins/logstash-input-snmp/issues/90). Fixes[#87](https://github.com/logstash-plugins/logstash-input-snmp/issues/87).
13
20
 
14
21
  ## 1.2.6
15
- - Docs: example on setting IPv6 hosts [#89](https://github.com/logstash-plugins/logstash-input-snmp/pull/89)
22
+ - [DOC] Add example on setting IPv6 hosts [#89](https://github.com/logstash-plugins/logstash-input-snmp/pull/89)
16
23
 
17
24
  ## 1.2.5
18
25
  - Updated snmp4j library to v2.8.4 [#86](https://github.com/logstash-plugins/logstash-input-snmp/pull/86)
data/README.md CHANGED
@@ -17,7 +17,7 @@ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/log
17
17
 
18
18
  ## Developing
19
19
 
20
- ### 1. Plugin Developement and Testing
20
+ ### 1. Plugin Development and Testing
21
21
 
22
22
  #### Code
23
23
  - To get started, you'll need JRuby with the Bundler gem installed.
data/docs/index.asciidoc CHANGED
@@ -54,7 +54,7 @@ libsmi is available and installable on most operating systems.
54
54
 
55
55
  To import a MIB, you need to first convert the ASN.1 MIB file into a `.dic` file using the libsmi `smidump` command line utility.
56
56
 
57
- Example (using `RFC1213-MIB` file)
57
+ *Example (using `RFC1213-MIB` file)*
58
58
 
59
59
  [source,sh]
60
60
  -----
@@ -63,6 +63,48 @@ $ smidump --level=1 -k -f python RFC1213-MIB > RFC1213-MIB.dic
63
63
 
64
64
  Note that the resulting file as output by `smidump` must have the `.dic` extension.
65
65
 
66
+ [id="plugins-{type}s-{plugin}-locate-mibs"]
67
+ ===== Preventing a `failed to locate MIB module` error
68
+
69
+ The `smidump` function looks for mib dependencies in its pre-configured path lists.
70
+ You may need to provide the paths to locations of MIBs in your particular environment.
71
+
72
+ You can avoid to avoid a `failed to locate MIB module` error by providing the additional path configuration information with:
73
+
74
+ * an environment variable, or
75
+ * a config file to provide the additional path configuration.
76
+
77
+ See the "MODULE LOCATIONS" section of the https://www.ibr.cs.tu-bs.de/projects/libsmi/smi_config.html[smi_config documentation] for more info.
78
+
79
+ [id="plugins-{type}s-{plugin}-env-var"]
80
+ ===== Option 1: Use an environment variable
81
+
82
+ Set the `SMIPATH` env var with the path to your mibs.
83
+ Be sure to include a prepended colon (`:`) for the path.
84
+
85
+ [source,sh]
86
+ -----
87
+ $ SMIPATH=":/path/to/mibs/" smidump -k -f python CISCO-PROCESS-MIB.mib > CISCO-PROCESS-MIB_my.dic <1>
88
+ -----
89
+ <1> Notice the colon that preceeds the path definition.
90
+
91
+ [id="plugins-{type}s-{plugin}-mib-config"]
92
+ ===== Option 2: Provide a coniguration file
93
+
94
+ The other approach is to create a configuration file with the `path` option. For example, you could create a file called `smi.conf`.
95
+
96
+ [source,sh]
97
+ -----
98
+ path :/path/to/mibs/
99
+ -----
100
+
101
+ Use the config with smidump:
102
+
103
+ [source,sh]
104
+ -----
105
+ $ smidump -c smi.conf -k -f python CISCO-PROCESS-MIB.mib > CISCO-PROCESS-MIB_my.dic
106
+ -----
107
+
66
108
  [id="plugins-{type}s-{plugin}-options"]
67
109
  ==== SNMP Input Configuration Options
68
110
 
@@ -157,11 +157,23 @@ module LogStash
157
157
  sub('MIB =', 'mib =')
158
158
 
159
159
  mib = nil
160
- eval(mib_hash)
160
+ silence_warnings do
161
+ eval(mib_hash)
162
+ end
161
163
  mib
162
164
  rescue Exception => e
163
165
  # rescuing Exception class is important here to rescue SyntaxError from eval
164
166
  raise(SnmpMibError, "error parsing mib dic file: #{filename}, error: #{e.message}")
165
167
  end
168
+
169
+ # MIB definition files may have duplicate entries that, since Ruby 2.7, generate warnings when they are converted to a hash.
170
+ # This method will suppress these warnings, unless `debug` logging is enabled.
171
+ def silence_warnings
172
+ warn_level = $VERBOSE
173
+ $VERBOSE = logger.debug? ? warn_level : nil
174
+ yield
175
+ ensure
176
+ $VERBOSE = warn_level
177
+ end
166
178
  end
167
179
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-snmp'
3
- s.version = '1.3.1'
3
+ s.version = '1.3.3'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = "SNMP input plugin"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -2,7 +2,7 @@ require "logstash/devutils/rspec/spec_helper"
2
2
  require "logstash/inputs/snmp"
3
3
 
4
4
  describe LogStash::Inputs::Snmp do
5
- let(:config) { {"get" => ["1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.3.0", "1.3.6.1.2.1.1.5.0"]} }
5
+ let(:config) { {"get" => %w[1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.3.0 1.3.6.1.2.1.1.5.0], "ecs_compatibility" => "disabled" } }
6
6
  let(:plugin) { LogStash::Inputs::Snmp.new(config)}
7
7
 
8
8
  shared_examples "snmp plugin return single event" do
@@ -114,8 +114,8 @@ describe LogStash::Inputs::Snmp do
114
114
  end
115
115
 
116
116
  describe "multiple pipelines and mix of udp tcp hosts", :integration => true do
117
- let(:config) { {"get" => ["1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:snmp1/161", "community" => "public"}]} }
118
- let(:config2) { {"get" => ["1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "tcp:snmp2/162", "community" => "public"}]} }
117
+ let(:config) { {"get" => ["1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:snmp1/161", "community" => "public"}], "ecs_compatibility" => "disabled" } }
118
+ let(:config2) { {"get" => ["1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "tcp:snmp2/162", "community" => "public"}], "ecs_compatibility" => "disabled"} }
119
119
  let(:plugin) { LogStash::Inputs::Snmp.new(config)}
120
120
  let(:plugin2) { LogStash::Inputs::Snmp.new(config2)}
121
121
 
@@ -148,10 +148,12 @@ describe LogStash::Inputs::Snmp do
148
148
  snmp {
149
149
  get => ["1.3.6.1.2.1.1.1.0"]
150
150
  hosts => [{host => "udp:snmp1/161" community => "public"}]
151
+ ecs_compatibility => "disabled"
151
152
  }
152
153
  snmp {
153
154
  get => ["1.3.6.1.2.1.1.1.0"]
154
155
  hosts => [{host => "tcp:snmp2/162" community => "public"}]
156
+ ecs_compatibility => "disabled"
155
157
  }
156
158
  }
157
159
  CONFIG
@@ -171,6 +173,7 @@ describe LogStash::Inputs::Snmp do
171
173
  priv_protocol => "aes"
172
174
  priv_pass => "STr0ngP@SSWRD161"
173
175
  security_level => "authPriv"
176
+ ecs_compatibility => "disabled"
174
177
  }
175
178
  snmp {
176
179
  get => ["1.3.6.1.2.1.1.1.0"]
@@ -181,6 +184,7 @@ describe LogStash::Inputs::Snmp do
181
184
  priv_protocol => "aes"
182
185
  priv_pass => "STr0ngP@SSWRD162"
183
186
  security_level => "authPriv"
187
+ ecs_compatibility => "disabled"
184
188
  }
185
189
  }
186
190
  CONFIG
@@ -390,5 +390,28 @@ describe LogStash::Inputs::Snmp, :ecs_compatibility_support do
390
390
  end
391
391
  end
392
392
  end
393
+
394
+ context "close" do
395
+ let(:config) do
396
+ <<-CONFIG
397
+ input {
398
+ snmp {
399
+ get => ["1.3.6.1.2.1.1.1.0"]
400
+ hosts => [{host => "udp:127.0.0.1/161" community => "public"}]
401
+ }
402
+ }
403
+ CONFIG
404
+ end
405
+
406
+ before(:each) do
407
+ expect(LogStash::SnmpClient).to receive(:new).and_return(mock_client)
408
+ expect(mock_client).to receive(:get).and_return({"foo" => "bar"})
409
+ end
410
+
411
+ it "should call the close method upon termination" do
412
+ expect(mock_client).to receive(:close).once
413
+ input(config) { }
414
+ end
415
+ end
393
416
  end
394
417
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-snmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2023-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -483,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
483
483
  - !ruby/object:Gem::Version
484
484
  version: '0'
485
485
  requirements: []
486
- rubygems_version: 3.1.6
486
+ rubygems_version: 3.2.33
487
487
  signing_key:
488
488
  specification_version: 4
489
489
  summary: SNMP input plugin