sensu-extensions-snmp-trap 0.0.30 → 0.0.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 685c31eceffb21bc8acbd3ed90424b912524a154
4
- data.tar.gz: 6899b9c27bbdb66b276ed9d2cb25c5e63e8ade5d
3
+ metadata.gz: 17e9844d75b6724daf2d8e32267c1906c439c1f7
4
+ data.tar.gz: 81e48a1e828bbc194c1618b3eb978308248b3ab9
5
5
  SHA512:
6
- metadata.gz: 07f81872568a1a16412d77b761f47cbcd0666a944fd50ee7c6cdf93fbeb1d112e5cb5efa00926006c7062f9919a55e740f06979ec7c533b674fbd96d62f34dca
7
- data.tar.gz: e499acae86185bd041973e0a30ef3147af8d74e7424d7ccf08b2e4b665fba43f015036941b50b9f7b2977a4971b5365848f86e2ed2808fb1d5e09a3037b842c4
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, "name"],
11
- [/notification/i, "output"],
12
- [/description/i, "output"],
13
- [/pansystemseverity/i, Proc.new { |value| value > 3 ? 2 : 0 }, "status"],
14
- [/severity/i, "status"]
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: name,
46
- publish: false
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
- @result_map = options[:mappings][:result] + RESULT_MAP
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
- @result_status_map = options[:mappings][:result_status] + RESULT_STATUS_MAP
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
- "source" => determine_hostname(trap.source_ip),
284
- "handlers" => options[:handlers],
285
- "snmp_trap" => {}
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["snmp_trap"][symbolic_name] = value
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["name"] ||= determine_trap_name(trap)
313
- result["output"] ||= determine_trap_output(trap)
314
- result["status"] ||= determine_trap_status(trap)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-extensions-snmp-trap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Extensions and contributors