logstash-input-snmp 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/docs/index.asciidoc +69 -2
- data/lib/logstash/inputs/snmp.rb +14 -3
- data/lib/logstash/inputs/snmp/base_client.rb +6 -6
- data/lib/logstash/inputs/snmp/mib.rb +10 -4
- data/logstash-input-snmp.gemspec +1 -1
- data/spec/inputs/snmp_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b52920a394a09244f4731933b5d79655002bd3569552ca33972dfd069d709ade
|
4
|
+
data.tar.gz: ff663bdff7ca249635388c68329cfcd0ae759893c4eaf27ff226ca59c6939f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de641478532900bd27fa9e261b239a0d7f87c2024ee20c59e70dce40a9bb5bbd369a6ec9b4b96c69571afafda62fb49940e458b2174bcf5d852de5e893106ef9
|
7
|
+
data.tar.gz: 0c63e9b7f357faba71b6120aeaf5b42adcb399307f630597e0858ef267a071487cbff47c6fe7422dcdf1441f4755182e511d9fe5902a3f4b86162b9bd5dc63c6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
|
+
## 1.2.0
|
2
|
+
- Adding oid_path_length config option [#59] (https://github.com/logstash-plugins/logstash-input-snmp/pull/59)
|
3
|
+
- Fixing bug with table support removing index value from OIDs [#60] )https://github.com/logstash-plugins/logstash-input-snmp/issues/60)
|
4
|
+
|
5
|
+
## 1.1.1
|
6
|
+
- Added information and other improvements to documentation [#57](https://github.com/logstash-plugins/logstash-input-snmp/pull/57)
|
7
|
+
|
1
8
|
## 1.1.0
|
2
|
-
- Added support for querying SNMP tables
|
9
|
+
- Added support for querying SNMP tables [#49] (https://github.com/logstash-plugins/logstash-input-snmp/pull/49)
|
3
10
|
- Changed three error messages in the base_client to include the target address for clarity in the logs.
|
4
11
|
|
5
12
|
## 1.0.1
|
data/docs/index.asciidoc
CHANGED
@@ -59,8 +59,10 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
59
59
|
| <<plugins-{type}s-{plugin}-hosts>> |<<array,array>>|No
|
60
60
|
| <<plugins-{type}s-{plugin}-interval>> |<<number,number>>|No
|
61
61
|
| <<plugins-{type}s-{plugin}-mib_paths>> |<<path,path>>|No
|
62
|
-
| <<plugins-{type}s-{plugin}-oid_root_skip>> |<<
|
62
|
+
| <<plugins-{type}s-{plugin}-oid_root_skip>> |<<number,number>>|No
|
63
|
+
| <<plugins-{type}s-{plugin}-oid_path_length>> |<<number,number>>|No
|
63
64
|
| <<plugins-{type}s-{plugin}-walk>> |<<array,array>>|No
|
65
|
+
| <<plugins-{type}s-{plugin}-tables>> |<<array,array>>|No
|
64
66
|
|=======================================================================
|
65
67
|
|
66
68
|
==== SNMPv3 Authentication Options
|
@@ -168,7 +170,7 @@ If you require other MIBs, you need to import them. See <<plugins-{type}s-{plugi
|
|
168
170
|
[id="plugins-{type}s-{plugin}-oid_root_skip"]
|
169
171
|
===== `oid_root_skip`
|
170
172
|
|
171
|
-
The `oid_root_skip` option specifies the
|
173
|
+
The `oid_root_skip` option specifies the number of OID root digits to ignore in the event field name.
|
172
174
|
For example, in a numeric OID like "1.3.6.1.2.1.1.1.0" the first 5 digits could be ignored by setting `oid_root_skip => 5`
|
173
175
|
which would result in a field name "1.1.1.0". Similarly when a MIB is used an OID such
|
174
176
|
"1.3.6.1.2.mib-2.system.sysDescr.0" would become "mib-2.system.sysDescr.0"
|
@@ -176,6 +178,17 @@ which would result in a field name "1.1.1.0". Similarly when a MIB is used an OI
|
|
176
178
|
* Value type is <<number,number>>
|
177
179
|
* Default value is `0`
|
178
180
|
|
181
|
+
[id="plugins-{type}s-{plugin}-oid_path_length"]
|
182
|
+
===== `oid_path_length`
|
183
|
+
|
184
|
+
The `oid_path_length` option specifies the number of OID root digits to retain in the event field name.
|
185
|
+
For example, in a numeric OID like "1.3.6.1.2.1.1.1.0" the last 2 digits could be retained by setting `oid_path_length => 2`
|
186
|
+
which would result in a field name "1.0". Similarly when a MIB is used an OID such
|
187
|
+
"1.3.6.1.2.mib-2.system.sysDescr.0" would become "sysDescr.0"
|
188
|
+
|
189
|
+
* Value type is <<number,number>>
|
190
|
+
* Default value is `0`
|
191
|
+
|
179
192
|
[id="plugins-{type}s-{plugin}-walk"]
|
180
193
|
===== `walk`
|
181
194
|
|
@@ -197,6 +210,41 @@ Example
|
|
197
210
|
}
|
198
211
|
-----
|
199
212
|
|
213
|
+
[id="plugins-{type}s-{plugin}-tables"]
|
214
|
+
===== `tables`
|
215
|
+
|
216
|
+
The `tables` option is used to query for tabular values for the given column OID(s).
|
217
|
+
|
218
|
+
Each table definition is a hash and must define the name key and value and the columns to return.
|
219
|
+
|
220
|
+
* Value type is <<array,array>>
|
221
|
+
* There is no default value for this setting
|
222
|
+
* Results are returned under a field using the table name
|
223
|
+
|
224
|
+
*Specifying a single table*
|
225
|
+
|
226
|
+
[source,ruby]
|
227
|
+
-----
|
228
|
+
input {
|
229
|
+
snmp {
|
230
|
+
hosts => [{host => "udp:127.0.0.1/161" community => "public" version => "2c" retries => 2 timeout => 1000}]
|
231
|
+
tables => [ {"name" => "interfaces" "columns" => ["1.3.6.1.2.1.2.2.1.1", "1.3.6.1.2.1.2.2.1.2", "1.3.6.1.2.1.2.2.1.5"]} ]
|
232
|
+
}
|
233
|
+
}
|
234
|
+
-----
|
235
|
+
|
236
|
+
*Specifying multiple tables*
|
237
|
+
|
238
|
+
[source,ruby]
|
239
|
+
-----
|
240
|
+
input {
|
241
|
+
snmp {
|
242
|
+
get => ["1.3.6.1.2.1.1.1.0"]
|
243
|
+
tables => [ {"name" => "interfaces" "columns" => ["1.3.6.1.2.1.2.2.1.1", "1.3.6.1.2.1.2.2.1.2", "1.3.6.1.2.1.2.2.1.5"]}, {"name" => "ltmPoolStatTable" "columns" => ["1.3.6.1.4.1.3375.2.2.5.2.3.1.1", "1.3.6.1.4.1.3375.2.2.5.2.3.1.6"]} ]
|
244
|
+
}
|
245
|
+
}
|
246
|
+
-----
|
247
|
+
|
200
248
|
==== SNMPv3 Authentication Options
|
201
249
|
|
202
250
|
A **single user** can be configured and will be used for all defined SNMPv3 hosts.
|
@@ -252,6 +300,25 @@ The `security_level` option specifies the SNMPv3 security level between Authenti
|
|
252
300
|
* Value can be any of: `noAuthNoPriv`, `authNoPriv`, `authPriv`
|
253
301
|
* There is no default value for this setting
|
254
302
|
|
303
|
+
*Specifying SNMPv3 settings*
|
304
|
+
|
305
|
+
[source,ruby]
|
306
|
+
-----
|
307
|
+
input {
|
308
|
+
snmp {
|
309
|
+
hosts => [{host => "udp:127.0.0.1/161" version => "3"}]
|
310
|
+
get => ["1.3.6.1.2.1.1.1.0"]
|
311
|
+
security_name => "mySecurityName"
|
312
|
+
auth_protocol => "sha"
|
313
|
+
auth_pass => "ShaPassword"
|
314
|
+
priv_protocol => "aes"
|
315
|
+
priv_pass => "AesPasword"
|
316
|
+
security_level => "authPriv"
|
317
|
+
}
|
318
|
+
}
|
319
|
+
|
320
|
+
-----
|
321
|
+
|
255
322
|
==== More configuration examples
|
256
323
|
|
257
324
|
*Using both `get` and `walk` in the same poll cycle for each host(s)*
|
data/lib/logstash/inputs/snmp.rb
CHANGED
@@ -56,6 +56,12 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
|
|
56
56
|
# as "1.3.6.1.2.mib-2.system.sysDescr.0" would become "mib-2.system.sysDescr.0"
|
57
57
|
config :oid_root_skip, :validate => :number, :default => 0
|
58
58
|
|
59
|
+
# number of OID tail digits to retain in event field name. For example, in a numeric OID
|
60
|
+
# like 1.3.6.1.2.1.1.1.0" the last 2 digits could be retained by setting oid_path_length => 2
|
61
|
+
# which would result in a field name "1.0". Similarly, when a MIB is used an OID such as
|
62
|
+
# "1.3.6.1.2.mib-2.system.sysDescr.0" would become "sysDescr.0"
|
63
|
+
config :oid_path_length, :validate => :number, :default => 0
|
64
|
+
|
59
65
|
# Set polling interval in seconds
|
60
66
|
#
|
61
67
|
# The default, `30`, means poll each host every 30 seconds.
|
@@ -95,6 +101,7 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
|
|
95
101
|
validate_oids!
|
96
102
|
validate_hosts!
|
97
103
|
validate_tables!
|
104
|
+
validate_strip!
|
98
105
|
|
99
106
|
mib = LogStash::SnmpMib.new
|
100
107
|
|
@@ -161,7 +168,7 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
|
|
161
168
|
result = {}
|
162
169
|
if !definition[:get].empty?
|
163
170
|
begin
|
164
|
-
result = result.merge(definition[:client].get(definition[:get], @oid_root_skip))
|
171
|
+
result = result.merge(definition[:client].get(definition[:get], @oid_root_skip, @oid_path_length))
|
165
172
|
rescue => e
|
166
173
|
logger.error("error invoking get operation on #{definition[:host_address]} for OIDs: #{definition[:get]}, ignoring", :exception => e, :backtrace => e.backtrace)
|
167
174
|
end
|
@@ -169,7 +176,7 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
|
|
169
176
|
if !definition[:walk].empty?
|
170
177
|
definition[:walk].each do |oid|
|
171
178
|
begin
|
172
|
-
result = result.merge(definition[:client].walk(oid, @oid_root_skip))
|
179
|
+
result = result.merge(definition[:client].walk(oid, @oid_root_skip, @oid_path_length))
|
173
180
|
rescue => e
|
174
181
|
logger.error("error invoking walk operation on OID: #{oid}, ignoring", :exception => e, :backtrace => e.backtrace)
|
175
182
|
end
|
@@ -179,7 +186,7 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
|
|
179
186
|
if !Array(@tables).empty?
|
180
187
|
@tables.each do |table_entry|
|
181
188
|
begin
|
182
|
-
result = result.merge(definition[:client].table(table_entry, @oid_root_skip))
|
189
|
+
result = result.merge(definition[:client].table(table_entry, @oid_root_skip, @oid_path_length))
|
183
190
|
rescue => e
|
184
191
|
logger.error("error invoking table operation on OID: #{table_entry['name']}, ignoring", :exception => e, :backtrace => e.backtrace)
|
185
192
|
end
|
@@ -277,4 +284,8 @@ class LogStash::Inputs::Snmp < LogStash::Inputs::Base
|
|
277
284
|
end
|
278
285
|
end
|
279
286
|
end
|
287
|
+
|
288
|
+
def validate_strip!
|
289
|
+
raise(LogStash::ConfigurationError, "you can not specify both oid_root_skip and oid_path_length") if @oid_root_skip > 0 and @oid_path_length > 0
|
290
|
+
end
|
280
291
|
end
|
@@ -45,7 +45,7 @@ module LogStash
|
|
45
45
|
transport.listen()
|
46
46
|
end
|
47
47
|
|
48
|
-
def get(oids, strip_root = 0)
|
48
|
+
def get(oids, strip_root = 0, path_length = 0)
|
49
49
|
pdu = get_pdu
|
50
50
|
Array(oids).each { |oid| pdu.add(VariableBinding.new(OID.new(oid))) }
|
51
51
|
|
@@ -66,14 +66,14 @@ module LogStash
|
|
66
66
|
variable = variable_binding.getVariable
|
67
67
|
value = coerce(variable)
|
68
68
|
|
69
|
-
result[@mib.map_oid(oid, strip_root)] = value
|
69
|
+
result[@mib.map_oid(oid, strip_root, path_length)] = value
|
70
70
|
end
|
71
71
|
|
72
72
|
result
|
73
73
|
end
|
74
74
|
|
75
75
|
|
76
|
-
def walk(oid, strip_root = 0)
|
76
|
+
def walk(oid, strip_root = 0, path_length = 0)
|
77
77
|
result = {}
|
78
78
|
|
79
79
|
pdufactory = get_pdu_factory
|
@@ -99,14 +99,14 @@ module LogStash
|
|
99
99
|
variable = var_binding.getVariable
|
100
100
|
value = coerce(variable)
|
101
101
|
|
102
|
-
result[@mib.map_oid(oid, strip_root)] = value
|
102
|
+
result[@mib.map_oid(oid, strip_root, path_length)] = value
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
result
|
107
107
|
end
|
108
108
|
|
109
|
-
def table(table, strip_root = 0)
|
109
|
+
def table(table, strip_root = 0, path_length = 0)
|
110
110
|
result = {}
|
111
111
|
rows = []
|
112
112
|
pdufactory = get_pdu_factory
|
@@ -140,7 +140,7 @@ module LogStash
|
|
140
140
|
oid = var_binding.getOid.toString
|
141
141
|
variable = var_binding.getVariable
|
142
142
|
value = coerce(variable)
|
143
|
-
mapped_oid = @mib.map_oid(oid, strip_root).
|
143
|
+
mapped_oid = @mib.map_oid(oid, strip_root, path_length).chomp('.'+idx_val)
|
144
144
|
row[mapped_oid] = value
|
145
145
|
end
|
146
146
|
rows << row
|
@@ -69,7 +69,7 @@ module LogStash
|
|
69
69
|
current.childs[last_node] = node
|
70
70
|
end
|
71
71
|
|
72
|
-
def map_oid(oid, strip_root = 0)
|
72
|
+
def map_oid(oid, strip_root = 0, path_length = 0)
|
73
73
|
path = Oid.parse(oid)
|
74
74
|
|
75
75
|
result = []
|
@@ -88,7 +88,13 @@ module LogStash
|
|
88
88
|
result << node.name
|
89
89
|
end
|
90
90
|
|
91
|
-
|
91
|
+
if strip_root > 0
|
92
|
+
result.drop(strip_root).join(".")
|
93
|
+
elsif path_length > 0
|
94
|
+
result.pop(path_length).join(".")
|
95
|
+
else
|
96
|
+
result.join(".")
|
97
|
+
end
|
92
98
|
end
|
93
99
|
end
|
94
100
|
|
@@ -136,8 +142,8 @@ module LogStash
|
|
136
142
|
[module_name, nodes]
|
137
143
|
end
|
138
144
|
|
139
|
-
def map_oid(oid, strip_root = 0)
|
140
|
-
@tree.map_oid(oid, strip_root)
|
145
|
+
def map_oid(oid, strip_root = 0, path_length = 0)
|
146
|
+
@tree.map_oid(oid, strip_root, path_length)
|
141
147
|
end
|
142
148
|
|
143
149
|
private
|
data/logstash-input-snmp.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-snmp'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.2.0'
|
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"
|
data/spec/inputs/snmp_spec.rb
CHANGED
@@ -22,6 +22,8 @@ describe LogStash::Inputs::Snmp do
|
|
22
22
|
[
|
23
23
|
{"get" => ["1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
24
24
|
{"get" => [".1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
25
|
+
{"get" => [".1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:127.0.0.1/161"}], "oid_root_skip" => 2},
|
26
|
+
{"get" => [".1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:127.0.0.1/161"}], "oid_path_length" => 2},
|
25
27
|
{"get" => ["1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1"], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
26
28
|
{"get" => ["1.3.6.1.2.1.1.1.0", ".1.3.6.1.2.1.1"], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
27
29
|
{"walk" => ["1.3.6.1.2.1.1.1"], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
@@ -35,6 +37,8 @@ describe LogStash::Inputs::Snmp do
|
|
35
37
|
{"get" => ["test"], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
36
38
|
{"get" => [], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
37
39
|
{"get" => "foo", "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
40
|
+
{"get" => [".1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:127.0.0.1/161"}], "oid_path_length" => "a" },
|
41
|
+
{"get" => [".1.3.6.1.2.1.1.1.0"], "hosts" => [{"host" => "udp:127.0.0.1/161"}], "oid_path_length" => 2, "oid_root_skip" => 2 },
|
38
42
|
{"walk" => "foo", "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
39
43
|
{"tables" => [{"columns" => ["1.2.3.4", "4.3.2.1"]}], "hosts" => [{"host" => "udp:127.0.0.1/161"}]},
|
40
44
|
]
|
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|