sensu-extensions-snmp-trap 0.0.30 → 0.0.31
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 +4 -4
- data/lib/sensu/extensions/snmp-trap.rb +24 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17e9844d75b6724daf2d8e32267c1906c439c1f7
|
4
|
+
data.tar.gz: 81e48a1e828bbc194c1618b3eb978308248b3ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 307d5098b043b4333f40b8b8e8feaf4b20cc4dbc0ec6bdfe491c9b0705eb46d9f3129f41aec87e4b4595d667f1ffd32c5727297ec68be58fd9aa4c1cbb738e71
|
7
|
+
data.tar.gz: 87dea0b54f9ac5962f2d665e4a65a99c0677045d2c6d8ec00fba0d91f0974e6e6540f7e529178190f2378e874b9173777dd0eed7a1c56cc66cefb5c5b646b0da
|
@@ -7,11 +7,11 @@ module Sensu
|
|
7
7
|
class SNMPTrap < Check
|
8
8
|
|
9
9
|
RESULT_MAP = [
|
10
|
-
[/checkname/i,
|
11
|
-
[/notification/i,
|
12
|
-
[/description/i,
|
13
|
-
[/pansystemseverity/i, Proc.new { |value| value > 3 ? 2 : 0 },
|
14
|
-
[/severity/i,
|
10
|
+
[/checkname/i, :name],
|
11
|
+
[/notification/i, :output],
|
12
|
+
[/description/i, :output],
|
13
|
+
[/pansystemseverity/i, Proc.new { |value| value > 3 ? 2 : 0 }, :status],
|
14
|
+
[/severity/i, :status]
|
15
15
|
]
|
16
16
|
|
17
17
|
RESULT_STATUS_MAP = [
|
@@ -42,8 +42,8 @@ module Sensu
|
|
42
42
|
|
43
43
|
def definition
|
44
44
|
{
|
45
|
-
name
|
46
|
-
publish
|
45
|
+
:name => name,
|
46
|
+
:publish => false
|
47
47
|
}
|
48
48
|
end
|
49
49
|
|
@@ -66,13 +66,20 @@ module Sensu
|
|
66
66
|
@options
|
67
67
|
end
|
68
68
|
|
69
|
+
def convert_to_mapping(configured_mapping)
|
70
|
+
configured_mapping.map do |mapping|
|
71
|
+
[Regexp.new(mapping.first), mapping.last.to_sym]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
69
75
|
def result_map
|
70
76
|
return @result_map if @result_map
|
71
77
|
if options[:mappings] &&
|
72
78
|
options[:mappings].is_a?(Hash) &&
|
73
79
|
options[:mappings][:result] &&
|
74
80
|
options[:mappings][:result].is_a?(Array)
|
75
|
-
|
81
|
+
configured_mapping = options[:mappings][:result]
|
82
|
+
@result_map = convert_to_mapping(configured_mapping) + RESULT_MAP
|
76
83
|
else
|
77
84
|
@result_map = RESULT_MAP
|
78
85
|
end
|
@@ -84,7 +91,8 @@ module Sensu
|
|
84
91
|
options[:mappings].is_a?(Hash) &&
|
85
92
|
options[:mappings][:result_status] &&
|
86
93
|
options[:mappings][:result_status].is_a?(Array)
|
87
|
-
|
94
|
+
configured_mapping = options[:mappings][:result_status]
|
95
|
+
@result_status_map = convert_to_mapping(configured_mapping) + RESULT_STATUS_MAP
|
88
96
|
else
|
89
97
|
@result_status_map = RESULT_STATUS_MAP
|
90
98
|
end
|
@@ -280,9 +288,9 @@ module Sensu
|
|
280
288
|
@logger.debug("snmp trap check extension processing a v2 trap")
|
281
289
|
result = options[:result_attributes].merge(
|
282
290
|
{
|
283
|
-
|
284
|
-
|
285
|
-
|
291
|
+
:source => determine_hostname(trap.source_ip),
|
292
|
+
:handlers => options[:handlers],
|
293
|
+
:snmp_trap => {}
|
286
294
|
}
|
287
295
|
)
|
288
296
|
trap.varbind_list.each do |varbind|
|
@@ -290,7 +298,7 @@ module Sensu
|
|
290
298
|
type_conversion = RUBY_ASN1_MAP[varbind.value.asn1_type]
|
291
299
|
if type_conversion
|
292
300
|
value = varbind.value.send(type_conversion)
|
293
|
-
result[
|
301
|
+
result[:snmp_trap][symbolic_name] = value
|
294
302
|
mapping = result_map.detect do |mapping|
|
295
303
|
symbolic_name =~ mapping.first
|
296
304
|
end
|
@@ -309,9 +317,9 @@ module Sensu
|
|
309
317
|
})
|
310
318
|
end
|
311
319
|
end
|
312
|
-
result[
|
313
|
-
result[
|
314
|
-
result[
|
320
|
+
result[:name] ||= determine_trap_name(trap)
|
321
|
+
result[:output] ||= determine_trap_output(trap)
|
322
|
+
result[:status] ||= determine_trap_status(trap)
|
315
323
|
send_result(result)
|
316
324
|
end
|
317
325
|
|