logstash-input-snmp 1.2.6 → 1.2.7

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: 149791948ca146c248ba111642501748a2c0eacedc6b5774e4c8dd02ce9fb746
4
- data.tar.gz: e5ac1d8d8d52481ea6b57a37ec09428a36b88c4c374c379aad3d5950c326e24a
3
+ metadata.gz: 755490661919181ec1b348c1b2bade1300a1829be66206b52c203a230c7a00fd
4
+ data.tar.gz: b05f137f91e3720ec567f620358c230b8ffe88f96c83d5158a9d05975b3e8ea6
5
5
  SHA512:
6
- metadata.gz: cfa32f9ecea52e10fcf38ece4ac80f2037da7a3dfed55560decba78eb80bdfc559a22952d8d85b83e44fbedcbe667b5f01d21d037406eea55a09fa5a684d4cee
7
- data.tar.gz: ec8eca95c464381397b581260803d238d1fb1bf57bd7ae8add5d2718aa438509f0be70473592ba07bb12d19abe5a8aaff49cb5208b010aff283e92782a91c4a4
6
+ metadata.gz: a3af3dba5c77fa3b6bec973a23eb8e3e0f8260287a6aa974d4cde6dd323193086d9767b2725600fc6e9776445e65bcb09e4e85883ffde331fe9e403eeba68edd
7
+ data.tar.gz: dfe8509aa8619a38616aeb23f534097f19ce06dd14f2c7d1bcb6874fcbdb14bf01fef88148b4cd06b20ed1fd766a03e81735cc96694ca6e28106ad4be649e0ab
@@ -1,3 +1,6 @@
1
+ ## 1.2.7
2
+ - Added integration tests to ensure SNMP server and IPv6 connections [#87](https://github.com/logstash-plugins/logstash-input-snmp/pull/87)
3
+
1
4
  ## 1.2.6
2
5
  - Docs: example on setting IPv6 hosts [#89](https://github.com/logstash-plugins/logstash-input-snmp/pull/89)
3
6
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-snmp'
3
- s.version = '1.2.6'
3
+ s.version = '1.2.7'
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"
@@ -0,0 +1,203 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/inputs/snmp"
3
+
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"]} }
6
+ let(:plugin) { LogStash::Inputs::Snmp.new(config)}
7
+
8
+ shared_examples "snmp plugin return single event" do
9
+ it "should have OID value" do
10
+ plugin.register
11
+ queue = []
12
+ stop_plugin_after_seconds(plugin)
13
+ plugin.run(queue)
14
+ plugin.close
15
+ event = queue.pop
16
+
17
+ expect(event).to be_a(LogStash::Event)
18
+ expect(event.get("iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.sysUpTimeInstance")).to be_a Integer
19
+ expect(event.get("iso.org.dod.internet.mgmt.mib-2.system.sysName.0")).to be_a String
20
+ expect(event.get("iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0")).to be_a String
21
+ end
22
+ end
23
+
24
+ shared_examples "snmp plugin return one udp event and one tcp event" do |config|
25
+ it "should have one udp from snmp1 and one tcp from snmp2" do
26
+ events = input(config) { |_, queue| 2.times.collect { queue.pop } }
27
+ udp = 0; tcp = 0
28
+ events.each { |event|
29
+ if event.get("[@metadata][host_protocol]") == "udp"
30
+ udp += 1
31
+ expect(event.get("[@metadata][host_protocol]")).to eq("udp")
32
+ expect(event.get("[@metadata][host_address]")).to eq("snmp1")
33
+ expect(event.get("[@metadata][host_port]")).to eq("161")
34
+ else
35
+ tcp += 1
36
+ expect(event.get("[@metadata][host_protocol]")).to eq("tcp")
37
+ expect(event.get("[@metadata][host_address]")).to eq("snmp2")
38
+ expect(event.get("[@metadata][host_port]")).to eq("162")
39
+ end
40
+ }
41
+ expect(udp).to eq(1)
42
+ expect(tcp).to eq(1)
43
+ end
44
+ end
45
+
46
+ describe "against single snmp server with snmpv2 and udp", :integration => true do
47
+ let(:config) { super.merge({"hosts" => [{"host" => "udp:snmp1/161", "community" => "public"}]})}
48
+ it_behaves_like "snmp plugin return single event"
49
+ end
50
+
51
+ describe "against single server with snmpv3 and tcp", :integration => true do
52
+ let(:config) { super.merge({
53
+ "hosts" => [{"host" => "tcp:snmp1/161", "version" => "3"}],
54
+ "security_name" => "user_1",
55
+ "auth_protocol" => "sha",
56
+ "auth_pass" => "STrP@SSPhr@sE",
57
+ "priv_protocol" => "aes",
58
+ "priv_pass" => "STr0ngP@SSWRD161",
59
+ "security_level" => "authPriv"
60
+ })}
61
+
62
+ it_behaves_like "snmp plugin return single event"
63
+ end
64
+
65
+ describe "invalid user against snmpv3 server", :integration => true do
66
+ let(:config) { super.merge({
67
+ "hosts" => [{"host" => "tcp:snmp1/161", "version" => "3"}],
68
+ "security_name" => "user_2",
69
+ "auth_protocol" => "sha",
70
+ "auth_pass" => "STrP@SSPhr@sE",
71
+ "priv_protocol" => "aes",
72
+ "priv_pass" => "STr0ngP@SSWRD161",
73
+ "security_level" => "authPriv"
74
+ })}
75
+
76
+ it "should have error log" do
77
+ expect(plugin.logger).to receive(:error).once
78
+ plugin.register
79
+ queue = []
80
+ stop_plugin_after_seconds(plugin)
81
+ plugin.run(queue)
82
+ plugin.close
83
+ end
84
+ end
85
+
86
+ describe "single input plugin on single server with snmpv2 and mix of udp and tcp", :integration => true do
87
+ let(:config) { super.merge({"hosts" => [{"host" => "udp:snmp1/161", "community" => "public"}, {"host" => "tcp:snmp1/161", "community" => "public"}]})}
88
+ it "should return two events " do
89
+ plugin.register
90
+ queue = []
91
+ stop_plugin_after_seconds(plugin)
92
+ plugin.run(queue)
93
+ plugin.close
94
+
95
+ host_cnt_snmp1 = queue.select {|event| event.get("host") == "snmp1"}.size
96
+ expect(queue.size).to eq(2)
97
+ expect(host_cnt_snmp1).to eq(2)
98
+ end
99
+ end
100
+
101
+ describe "single input plugin on multiple udp hosts", :integration => true do
102
+ let(:config) { super.merge({"hosts" => [{"host" => "udp:snmp1/161", "community" => "public"}, {"host" => "udp:snmp2/162", "community" => "public"}]})}
103
+ it "should return two events, one per host" do
104
+ plugin.register
105
+ queue = []
106
+ stop_plugin_after_seconds(plugin)
107
+ plugin.run(queue)
108
+ plugin.close
109
+
110
+ hosts = queue.map { |event| event.get("host") }.sort
111
+ expect(queue.size).to eq(2)
112
+ expect(hosts).to eq(["snmp1", "snmp2"])
113
+ end
114
+ end
115
+
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"}]} }
119
+ let(:plugin) { LogStash::Inputs::Snmp.new(config)}
120
+ let(:plugin2) { LogStash::Inputs::Snmp.new(config2)}
121
+
122
+ it "should return two events, one per host" do
123
+ plugin.register
124
+ plugin2.register
125
+ queue = []
126
+ queue2 = []
127
+ t = Thread.new {
128
+ stop_plugin_after_seconds(plugin)
129
+ plugin.run(queue)
130
+ }
131
+ t2 = Thread.new {
132
+ stop_plugin_after_seconds(plugin2)
133
+ plugin2.run(queue2)
134
+ }
135
+ t.join(2100)
136
+ t2.join(2100)
137
+ plugin.close
138
+ plugin2.close
139
+
140
+ hosts = [queue.pop, queue2.pop].map { |event| event.get("host") }.sort
141
+ expect(hosts).to eq(["snmp1", "snmp2"])
142
+ end
143
+ end
144
+
145
+ describe "multiple plugin inputs and mix of udp tcp hosts", :integration => true do
146
+ config = <<-CONFIG
147
+ input {
148
+ snmp {
149
+ get => ["1.3.6.1.2.1.1.1.0"]
150
+ hosts => [{host => "udp:snmp1/161" community => "public"}]
151
+ }
152
+ snmp {
153
+ get => ["1.3.6.1.2.1.1.1.0"]
154
+ hosts => [{host => "tcp:snmp2/162" community => "public"}]
155
+ }
156
+ }
157
+ CONFIG
158
+
159
+ it_behaves_like "snmp plugin return one udp event and one tcp event", config
160
+ end
161
+
162
+ describe "two plugins on different hosts with snmpv3 with same security name with different credentials and mix of udp and tcp", :integration => true do
163
+ config = <<-CONFIG
164
+ input {
165
+ snmp {
166
+ get => ["1.3.6.1.2.1.1.1.0"]
167
+ hosts => [{host => "udp:snmp1/161" version => "3"}]
168
+ security_name => "user_1"
169
+ auth_protocol => "sha"
170
+ auth_pass => "STrP@SSPhr@sE"
171
+ priv_protocol => "aes"
172
+ priv_pass => "STr0ngP@SSWRD161"
173
+ security_level => "authPriv"
174
+ }
175
+ snmp {
176
+ get => ["1.3.6.1.2.1.1.1.0"]
177
+ hosts => [{host => "tcp:snmp2/162" version => "3"}]
178
+ security_name => "user_1"
179
+ auth_protocol => "sha"
180
+ auth_pass => "STrP@SSPhr@sE"
181
+ priv_protocol => "aes"
182
+ priv_pass => "STr0ngP@SSWRD162"
183
+ security_level => "authPriv"
184
+ }
185
+ }
186
+ CONFIG
187
+
188
+ it_behaves_like "snmp plugin return one udp event and one tcp event", config
189
+ end
190
+
191
+ describe "single host with tcp over ipv6", :integration => true do
192
+ let(:config) { super.merge({"hosts" => [{"host" => "tcp:[2001:3984:3989::161]/161"}]})}
193
+ it_behaves_like "snmp plugin return single event"
194
+ end
195
+
196
+ def stop_plugin_after_seconds(plugin)
197
+ Thread.new{
198
+ sleep(2)
199
+ plugin.do_stop
200
+ }
201
+ end
202
+
203
+ end
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.2.6
4
+ version: 1.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-21 00:00:00.000000000 Z
11
+ date: 2020-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -414,6 +414,7 @@ files:
414
414
  - logstash-input-snmp.gemspec
415
415
  - spec/fixtures/RFC1213-MIB.dic
416
416
  - spec/fixtures/collision.dic
417
+ - spec/inputs/integration/it_spec.rb
417
418
  - spec/inputs/snmp/base_client_spec.rb
418
419
  - spec/inputs/snmp/mib_spec.rb
419
420
  - spec/inputs/snmp_spec.rb
@@ -448,6 +449,7 @@ summary: SNMP input plugin
448
449
  test_files:
449
450
  - spec/fixtures/RFC1213-MIB.dic
450
451
  - spec/fixtures/collision.dic
452
+ - spec/inputs/integration/it_spec.rb
451
453
  - spec/inputs/snmp/base_client_spec.rb
452
454
  - spec/inputs/snmp/mib_spec.rb
453
455
  - spec/inputs/snmp_spec.rb